maven 公共模块依赖_找不到Maven多模块依赖包

I've got a multi module project: The parent POM.xml:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

1.4.3.RELEASE

be.bodyreset

bodyreset-parent

1.0.0-SNAPSHOT

pom

Bodyreset Parent

Manages the common properties and dependencies for the child modules

bodyreset-commons

messaging-contract

discovery-microservice

api-gateway-microservice

rest-client-microservice

email-commons

security-microservice

user-microservice

point-of-service-microservice

bodyreset

1.8

1.6.6

...

com.spotify

docker-maven-plugin

0.4.11

org.apache.maven.plugins

maven-compiler-plugin

3.6.0

${java.version}

${java.version}

org.apache.maven.plugins

maven-jar-plugin

3.0.2

The POM.xml of the rest-client-microservice looks like this:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

be.bodyreset

bodyreset-parent

1.0.0-SNAPSHOT

rest-client-microservice

1.0.0-SNAPSHOT

jar

Rest Client Microservice

Manages the REST clients to use for inter-service communication

org.apache.commons

commons-lang3

org.projectlombok

lombok

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-hateoas

org.springframework.boot

spring-boot-starter-test

test

org.springframework.cloud

spring-cloud-starter-eureka

org.springframework.cloud

spring-cloud-starter-feign

org.springframework.cloud

spring-cloud-starter-hystrix

com.spotify

docker-maven-plugin

package

build

${docker.image.prefix}/${project.artifactId}

${project.basedir}/src/main/docker

/

${project.build.directory}

${project.build.finalName}.jar

org.apache.maven.plugins

maven-jar-plugin

test-jar

org.springframework.boot

spring-boot-maven-plugin

repackage

The POM.xml of the email-commons module looks as follows:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

be.bodyreset

bodyreset-parent

1.0.0-SNAPSHOT

email-commons

1.0.0-SNAPSHOT

jar

Email Commons

Enables sending emails via SMPT

be.bodyreset

rest-client-microservice

1.0.0-SNAPSHOT

be.bodyreset

rest-client-microservice

1.0.0-SNAPSHOT

test-jar

test

org.apache.commons

commons-lang3

org.projectlombok

lombok

org.powermock

powermock-api-mockito

test

org.powermock

powermock-module-junit4

test

org.springframework.boot

spring-boot-starter-mail

org.springframework.boot

spring-boot-starter-thymeleaf

org.springframework.boot

spring-boot-starter-test

test

org.apache.maven.plugins

maven-jar-plugin

test-jar

If I try to perform a maven clean install on the parent project, I get the following result:

[INFO] ------------------------------------------------------------------------

[INFO] Building Email Commons 1.0.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ email-commons ---

[INFO] Deleting /home/developer/ideaProjects/bodyreset/email-commons/target

[INFO]

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ email-commons ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] Copying 0 resource

[INFO] Copying 2 resources

[INFO]

[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ email-commons ---

[INFO] Changes detected - recompiling the module!

[INFO] Compiling 17 source files to /home/developer/ideaProjects/bodyreset/email-commons/target/classes

[INFO] -------------------------------------------------------------

[ERROR] COMPILATION ERROR :

[INFO] -------------------------------------------------------------

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToRecipientConverter.java:[4,29] package be.bodyreset.rest.dto does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToRecipientConverter.java:[16,63] cannot find symbol

symbol: class UserDTO

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToRecipientConverter.java:[22,30] cannot find symbol

symbol: class UserDTO

location: class be.bodyreset.mail.converter.UserDTOToRecipientConverter

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[4,29] package be.bodyreset.rest.dto does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[5,29] package be.bodyreset.rest.dto does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[15,60] cannot find symbol

symbol: class UserDTO

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[21,27] cannot find symbol

symbol: class UserDTO

location: class be.bodyreset.mail.converter.UserDTOToSenderConverter

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[7,32] package be.bodyreset.rest.client does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[8,32] package be.bodyreset.rest.client does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[9,29] package be.bodyreset.rest.dto does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[10,29] package be.bodyreset.rest.dto does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[34,13] cannot find symbol

symbol: class PointOfServiceClient

location: class be.bodyreset.mail.service.impl.SenderServiceImpl

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[37,13] cannot find symbol

symbol: class UserClient

location: class be.bodyreset.mail.service.impl.SenderServiceImpl

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[63,13] cannot find symbol

symbol: class PointOfServiceDTO

location: class be.bodyreset.mail.service.impl.SenderServiceImpl

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/RecipientServiceImpl.java:[7,32] package be.bodyreset.rest.client does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/RecipientServiceImpl.java:[8,29] package be.bodyreset.rest.dto does not exist

[ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/RecipientServiceImpl.java:[32,13] cannot find symbol

symbol: class UserClient

location: class be.bodyreset.mail.service.impl.RecipientServiceImpl

[INFO] 17 errors

[INFO] -------------------------------------------------------------

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary:

[INFO]

[INFO] Bodyreset Parent .................................. SUCCESS [0.690s]

[INFO] Bodyreset Commons ................................. SUCCESS [7.444s]

[INFO] Messaging Contract ................................ SUCCESS [1.751s]

[INFO] Discovery Microservice ............................ SUCCESS [19.925s]

[INFO] API Gateway Microservice .......................... SUCCESS [17.272s]

[INFO] Rest Client Microservice .......................... SUCCESS [15.271s]

[INFO] Email Commons ..................................... FAILURE [1.026s]

[INFO] Security Microservice ............................. SKIPPED

[INFO] User Microservice ................................. SKIPPED

[INFO] Point Of Service Microservice ..................... SKIPPED

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1:04.292s

[INFO] Finished at: Thu Jan 19 11:53:25 CET 2017

[INFO] Final Memory: 63M/656M

[INFO] ------------------------------------------------------------------------

I've been breaking my head on this issue for several days now, but I don't have a clue why this isn't working.

解决方案

I figured it out. The rest-client-microservice is a Spring Boot project and uses the following plugin:

org.springframework.boot

spring-boot-maven-plugin

repackage

The jar is repackaged and all the packages and classes are put in the BOOT-INF folder. That's the reason why Maven is unable to find them. You can fix this by defining the plugin like this:

org.springframework.boot

spring-boot-maven-plugin

repackage

exec

With this configuration, the Spring Boot Maven Plugin will create 2 JARs: the main one will be the same as a usual Maven project, while the second one will have the classifier appended and be the executable JAR.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值