当前位置:   article > 正文

微服务多模块项目maven打包时报找不到依赖模块中的类_maven多模块打包 找不到类

maven多模块打包 找不到类

现在有个微服务项目,里面ServiceProvider模块依赖Common模块,依赖是这么添加的

<!--添加common项目依赖-->
<dependency>
    <groupId>com.figo</groupId>
    <artifactId>Common</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

正常的开发调试时没有问题,但是通过mvn打包时报错:

[WARNING] The POM for com.figo:Common:jar:0.0.1-SNAPSHOT is missing, no dependency information available

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project ServiceProvider: Compilation failure: Compilation failure:
[ERROR] /E:/IdeaProjects/UPPoint/PointServiceProvider/src/main/java/com/figo/serviceprovider/controller/TestController.java:[3,38] 程序包com.figo.common.utils不存在

解决办法:

1.Common模块pom.xml里面build需要将spring-boot-maven-plugin注释

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-compiler-plugin</artifactId>
  6. <version>3.8.1</version>
  7. <configuration>
  8. <source>1.8</source>
  9. <target>1.8</target>
  10. <encoding>UTF-8</encoding>
  11. </configuration>
  12. </plugin>
  13. <!-- 需要注释,不然Provider模块无法引用,因为Provider是web模块,里面也有mainClass
  14. <plugin>
  15. <groupId>org.springframework.boot</groupId>
  16. <artifactId>spring-boot-maven-plugin</artifactId>
  17. <version>2.3.7.RELEASE</version>
  18. <configuration>
  19. <mainClass>com.figo.common.CommonApplication</mainClass>
  20. </configuration>
  21. <executions>
  22. <execution>
  23. <id>repackage</id>
  24. <goals>
  25. <goal>repackage</goal>
  26. </goals>
  27. </execution>
  28. </executions>
  29. </plugin>
  30. -->
  31. </plugins>
  32. </build>

2.先打Common包

E:\IdeaProjects\MyProject\Common>mvn clean install -Dmaven.skip.test=true

3.再打ServiceProvider包

E:\IdeaProjects\MyProject\ServiceProvider>mvn clean install -Dmaven.skip.test=true

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/313353
推荐阅读
相关标签
  

闽ICP备14008679号