依赖java的spring启动应用程序启动,而不是主模块sbt
我在sbt中有一个多模块项目设置,配置如下:
模块signup
:spring boot 2.4.4
模块ui
:spring 5.4.5(非spring boot)
项目级build.sbt
有以下lazy val ui = (project in file("ui")).dependsOn(signup % "test->test;compile->compile")
我正在使用以下插件来构建ui
模块的addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.2.2")
war文件
问题是:当我在tomcat中部署UI模块的war文件时,它不是启动UI模块,而是启动注册模块(因为注册也有单独运行它的主类)
该项目使用较低版本的依赖项,比如spring boot 2.1.2.RELEASE
使用最新版本的依赖项时的日志如下:
22-Mar-2021 15:45:22.116 INFO [Catalina-utility-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.4)
[WARN ] 2021-03-22 15:45:27.509 [Catalina-utility-1] AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
它失败了,因为它需要application.properties
文件中的jdbc属性。但这是正在运行的signup
模块,它需要jdbc
属性。理想情况下,它不应该在部署UI模块的war文件时启动,它只依赖于类/方法的注册模块
请指导我应该以何种方式继续为这个问题找到解决方案。另外,如果您需要关于某些代码的更多信息,请告诉我
更新:
如果我注释掉注册模块的main
spring引导类,那么项目就可以正常工作。现在,我正在研究如何在创建war文件时删除特定类
共 (0) 个答案