Maven的依賴我有這個架構與子多模塊
mmsb
|----pom.xml (packaging : pom) -> declare modules API and Utils
|----api
| |----pom.xml (packaging : pom) -> declare module api-slack/parent project
| |----api-slack
| |----pom.xml (packaging : pom) -> declare module api-slack-core/parent api
| |----api-slack-core
| |----pom.xml (packaging : jar) -> java code/parent api-slack
|----utils
| |----pom.xml (packaging : jar) -> java code/parent project/has dependency from api-slack-core
|
而且它不工作
隨着清潔從根Maven的安裝說:
~/dev/maven-multi-sub-projets ⌚ 11:03:48
$ mvn clean install -DskipTests
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] mmsb
[INFO] api
[INFO] api-slack
[INFO] api-slack-core
[INFO] utils
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mmsb 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ mmsb ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ mmsb ---
[INFO] Installing /home/mario/dev/maven-multi-sub-projets/pom.xml to /opt/maven/m2repo/fr/app/mmsb/1.0-SNAPSHOT/mmsb-1.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building api 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ api ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ api ---
[INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/pom.xml to /opt/maven/m2repo/fr/app/api/1.0-SNAPSHOT/api-1.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building api-slack 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ api-slack ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ api-slack ---
[INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/api-slack/pom.xml to /opt/maven/m2repo/fr/app/api-slack/1.0-SNAPSHOT/api-slack-1.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building api-slack-core 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ api-slack-core ---
[INFO] Deleting /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ api-slack-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ api-slack-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ api-slack-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ api-slack-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ api-slack-core ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ api-slack-core ---
[INFO] Building jar: /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target/api-slack-core-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.4.2.RELEASE:repackage (default) @ api-slack-core ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ api-slack-core ---
[INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/target/api-slack-core-1.0-SNAPSHOT.jar to /opt/maven/m2repo/fr/app/api-slack-core/1.0-SNAPSHOT/api-slack-core-1.0-SNAPSHOT.jar
[INFO] Installing /home/mario/dev/maven-multi-sub-projets/api/api-slack/api-slack-core/pom.xml to /opt/maven/m2repo/fr/app/api-slack-core/1.0-SNAPSHOT/api-slack-core-1.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building utils 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ utils ---
[INFO] Deleting /home/mario/dev/maven-multi-sub-projets/utils/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ utils ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ utils ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/mario/dev/maven-multi-sub-projets/utils/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[3,29] package fr.app.api.slack.core does not exist
[ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[11,13] cannot find symbol
symbol: class SlackService
location: class fr.app.utils.Application
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] mmsb ............................................... SUCCESS [ 0.213 s]
[INFO] api ................................................ SUCCESS [ 0.005 s]
[INFO] api-slack .......................................... SUCCESS [ 0.004 s]
[INFO] api-slack-core ..................................... SUCCESS [ 1.558 s]
[INFO] utils .............................................. FAILURE [ 0.113 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.197 s
[INFO] Finished at: 2016-12-15T11:03:52+01:00
[INFO] Final Memory: 32M/317M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project utils: Compilation failure: Compilation failure:
[ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[3,29] package fr.app.api.slack.core does not exist
[ERROR] /home/mario/dev/maven-multi-sub-projets/utils/src/main/java/fr/app/utils/Application.java:[11,13] cannot find symbol
[ERROR] symbol: class SlackService
[ERROR] location: class fr.app.utils.Application
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :utils
如何聲明API-的依賴utils中的slack-core?
UPDATE
我上傳的代碼在這個倉庫:https://github.com/mmaryo/mmsb
問題是,當我輸入fr.app.api.slack.core.SlackService內fr.app.utils.Application
更新2
我發現這個問題,我刪除了:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
你是否已經從根模塊執行'mvn clean install'? – davidxxx
是的,它是乾淨的從根安裝 – Maryo
好的。你可以展示Utils和Api-slack-core模塊的pom嗎? – davidxxx