我正在使用Gradle构建并将一个非常简单的spring boot应用程序(99%静态内容)打包到一个带有嵌入式tomcat的jar中.
我尝试创建所述jar,起初结果是86k并且没有启动,因为它缺少一些Spring启动类.我总结说这个jar我没有包含任何应用程序的依赖项,因为我确实想要一个完全独立的jar,我应该做更多的研究.
这是我发现将该from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }部分添加到'jar' 的建议,这导致它引入所有依赖项.(我希望).我熟悉三元运算符的概念,我可以看到它在这里尝试做什么.
不幸的是它仍然无法正常工作!这是我在启动时遇到的错误,下面是我的build.gradle.
我想要一个完全包含在jar中的嵌入式tomcat的spring boot应用程序.我在做一些非常规的事吗?
在这一点上任何帮助将不胜感激.
(About 80 lines of successful Spring Boot launch messages followed immediately by:
18:16:54.890 [main] WARN o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132) [SpringWsTest1.jar:na]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) ~[SpringWsTest1.jar:na]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117) [SpringWsTest1.jar:na]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689) [SpringWsTest1.jar:na]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) [SpringWsTest1.jar:na]
at …Run Code Online (Sandbox Code Playgroud)