java – SpringBoot:运行一个多模块项目

前端之家收集整理的这篇文章主要介绍了java – SpringBoot:运行一个多模块项目前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个基本的SpringBoot应用程序.使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎和包作为可执行的JAR文件.
是一个带有Spring Boot的多模块项目,该项目将有3个模块.
这里是父模块pom.xml

这里是模块核心

这里是模块网:

从父根我使用以下方法生成所有模块:

mvn clean package

但问题是tdk-web-0.0.2-SNAPSHOT.jar不包含tdk-core-0.0.2-SNAPSHOT.jar然后在启动时失败

这里的maven结果:

MacBook-Pro-de-nunito:tdk-cloud calzada$mvn clean package -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] tdk-cloud
[INFO] tdk-core
[INFO] tdk-batch
[INFO] tdk-web
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building tdk-cloud 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ tdk-cloud ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building tdk-core 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.h2database:h2:jar:1.4.194 is missing,no dependency information available
[INFO] 
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ tdk-core ---
[INFO] Deleting /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-core/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tdk-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tdk-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 52 source files to /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-core/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tdk-core ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ tdk-core ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ tdk-core ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ tdk-core ---
[INFO] Building jar: /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-core/target/tdk-core-0.0.2-SNAPSHOT.jar
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building tdk-batch 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ tdk-batch ---
[INFO] Deleting /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-batch/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tdk-batch ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-batch/src/main/resources
[INFO] skip non existing resourceDirectory /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-batch/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tdk-batch ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-batch/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tdk-batch ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ tdk-batch ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ tdk-batch ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ tdk-batch ---
[INFO] Building jar: /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-batch/target/tdk-batch-0.0.2-SNAPSHOT.jar
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building tdk-web 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ tdk-web ---
[INFO] Deleting /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-web/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tdk-web ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 339 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tdk-web ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 25 source files to /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-web/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tdk-web ---
[INFO] Not copying test resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ tdk-web ---
[INFO] Not compiling test sources
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ tdk-web ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ tdk-web ---
[INFO] Building jar: /Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/tdk-cloud/tdk-web/target/tdk-web-0.0.2-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.5.3.RELEASE:repackage (default) @ tdk-web ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] tdk-cloud ....................................... SUCCESS [  0.105 s]
[INFO] tdk-core ........................................ SUCCESS [  1.634 s]
[INFO] tdk-batch ....................................... SUCCESS [  0.114 s]
[INFO] tdk-web ......................................... SUCCESS [  1.506 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.663 s
[INFO] Finished at: 2017-05-30T05:37:04+02:00
[INFO] Final Memory: 47M/539M
[INFO] ------------------------------------------------------------------------
MacBook-Pro-de-nunito:tdk-cloud calzada$

这是我得到的错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field emailService in com.tdkcloud.web.controllers.AppErrorController required a bean of type 'com.tdkcloud.backend.service.EmailService' that could not be found.


Action:

Consider defining a bean of type 'com.tdkcloud.backend.service.EmailService' in your configuration.

我解压缩了jar,并没有核心模块的类

将建议的代码添加到模块Web:

我有下一个错误:错误解析模板“/ tdk / login / login”,模板可能不存在或任何配置的模板Reso可能无法访问

但模板在那里:

enter image description here

最佳答案
最近,我尝试将我的项目结构/布局之一实现为maven多模块项目.

我按照以下春季指南链接,希望这将有助于你和其他人
Official Spring multi module project link

原文链接:https://www.f2er.com/springboot/432470.html

猜你在找的Springboot相关文章