英文:
Maven can't find package
问题
以下是您提供的代码的翻译:
第一个模块的 pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.fakenews.commons</groupId>
<artifactId>fakenewsCommons</artifactId>
<version>0.0.4-SNAPSHOT</version>
<name>fakenewsCommons</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
第二个模块的 pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.fakenews.scraper.api</groupId>
<artifactId>fakenewsScraperApi</artifactId>
<version>0.0.4-SNAPSHOT</version>
<name>fakenewsScraperApi</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fakenews.commons</groupId>
<artifactId>fakenewsCommons</artifactId>
<version>0.0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
请注意,这里只是提供了您代码的翻译部分,不包括其他内容。
英文:
I am developing a project in maven, and I have created 2 modules, one for the entities
Here the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.fakenews.commons</groupId>
<artifactId>fakenewsCommons</artifactId>
<version>0.0.4-SNAPSHOT</version>
<name>fakenewsCommons</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
And the other module makes use of this one through dependencies in the pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.fakenews.scraper.api</groupId>
<artifactId>fakenewsScraperApi</artifactId>
<version>0.0.4-SNAPSHOT</version>
<name>fakenewsScraperApi</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fakenews.commons</groupId>
<artifactId>fakenewsCommons</artifactId>
<version>0.0.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
I have already compiled the first module with the entities with
> mvn clean install
and I have verified that:
- the .jar has been created in the folder ~ / .m2 / repository / com / fakenews / commons / fakenewsCommons / 0.0.4-SNAPSHOT
but when i compile the main module with
> mvn clean install
maven can't find the package.
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[3,55] package com.fakenews.commons.fakenewsCommons.models.dao does not exist
Here the output with
> mvn clean install -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< com.fakenews.scraper.api:fakenewsScraperApi >-------------
[INFO] Building fakenewsScraperApi 0.0.4-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ fakenewsScraperApi ---
[INFO] Deleting /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ fakenewsScraperApi ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ fakenewsScraperApi ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[3,55] package com.fakenews.commons.fakenewsCommons.models.dao does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[4,58] package com.fakenews.commons.fakenewsCommons.models.entity does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[3,58] package com.fakenews.commons.fakenewsCommons.models.entity does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[14,5] cannot find symbol
symbol: class NewRepository
location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[18,17] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[24,12] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[30,21] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[30,12] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[8,17] cannot find symbol
symbol: class New
location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[9,12] cannot find symbol
symbol: class New
location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[10,21] cannot find symbol
symbol: class New
location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[10,12] cannot find symbol
symbol: class New
location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[19,17] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.controllers.NewController
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[27,12] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.controllers.NewController
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[3,1] package com.fakenews.commons.fakenewsCommons.models.entity does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[19,22] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[28,9] cannot find symbol
symbol: class New
location: class com.fakenews.scraper.api.fakenewsScraperApi.controllers.NewController
[INFO] 17 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.586 s
[INFO] Finished at: 2020-09-11T17:23:36+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project fakenewsScraperApi: Compilation failure: Compilation failure:
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[3,55] package com.fakenews.commons.fakenewsCommons.models.dao does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[4,58] package com.fakenews.commons.fakenewsCommons.models.entity does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[3,58] package com.fakenews.commons.fakenewsCommons.models.entity does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[14,5] cannot find symbol
[ERROR] symbol: class NewRepository
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[18,17] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[24,12] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[30,21] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[30,12] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[8,17] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[9,12] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[10,21] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/INewService.java:[10,12] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: interface com.fakenews.scraper.api.fakenewsScraperApi.service.INewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[19,17] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.controllers.NewController
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[27,12] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.controllers.NewController
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[3,1] package com.fakenews.commons.fakenewsCommons.models.entity does not exist
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/service/NewService.java:[19,22] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.service.NewService
[ERROR] /Users/asax/Documents/workspace-fake-news/fakenewsScraperApi/src/main/java/com/fakenews/scraper/api/fakenewsScraperApi/controllers/NewController.java:[28,9] cannot find symbol
[ERROR] symbol: class New
[ERROR] location: class com.fakenews.scraper.api.fakenewsScraperApi.controllers.NewController
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project fakenewsScraperApi: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:39)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:122)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1220)
at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:187)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:39)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:122)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
<<<<<< EDIT
I use IntelliJ and the maven module of IntelliJ Ommited the Spring-boot-starter-jpa , i don't know if it's normal.
答案1
得分: 4
我的解决方案在这里:
https://www.baeldung.com/spring-boot-dependency
或者您可以只删除以下部分:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
在 spring-boot 项目中作为一个依赖。
英文:
My solution is here :
https://www.baeldung.com/spring-boot-dependency
or you can just delete
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
On the spring-boot project as a dependency
答案2
得分: 2
据我所知,如果您使用父级 spring-boot-starter-parent
构建了一个 JAR 文件,您将无法将其用作依赖项。
英文:
AFAIK, you cannot use a jar as dependency if you build it with the parent spring-boot-starter-parent
.
答案3
得分: 1
在我看来,问题出现在您的父级pom中,您应该创建一个类似于以下项目结构
application => pom.xml
- common => pom.xml
- API => pom.xml
- 在 application => pom.xml 中,创建一个打包为pom的模块,添加模块 common 和 api。您可能需要添加一个父级来扩展Spring Boot。别忘了添加 dependencyManagement。
- 在 common => pom.xml 中,创建一个打包为jar的模块,父级为 application。您可以添加用于 common 模块的依赖。
- 在 API => pom.xml 中,创建一个打包为jar的模块,父级为 application。您可以在这里添加 Spring JPA 依赖。
然后将 common 作为共享库引入,与您之前的操作相同。
英文:
IMO, the problem come from your parent pom, you should create a project structure like
application => pom.xml
- common => pom.xml
- API => pom.xml
- application => pom.xml package pom, add modules common, api. you may add a parent to extend spring boot. Dont forget add dependencyManagement
- common => pom.xml package jar, parent = application. you can add dependency which used for common
- API => pom.xml package jar, parent = application. You can add spring JPA dependencies here
then enjoin you common as a shared library same as what you did
答案4
得分: 1
这样做会更好,如果你创建一个父级 pom.xml,并将 commons 项目作为一个模块添加进去。
这样你可以在父级 pom 中使用公共依赖,而各个模块也可以使用它们。
英文:
It is much better if you create a parent pom.xml and add the commons project as a module.
So you can use the common dependencies in the parent pom and the modules can use them.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论