【发布时间】:2015-12-02 07:50:14
【问题描述】:
我是 Spring Boot 新手,未能创建自包含的可执行 jar。 Maven 创建的 jar 无法在运行时检测到它需要的 Bean。
Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
如果工厂的实现在 jar 中,我检查了工厂。我还仔细检查了其他帖子,并确保 Spring Boot 注释到位。它包括@ComponentScan 和其他。
@SpringBootApplication
public class InitService {
我假设我的 pom 已正确设置了依赖项,因为当我从 Eclipse 项目启动应用程序时,它运行良好。
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>de.newbe.create.InitService</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
所以现在我向社区发起挑战,希望得到您宝贵的专业知识和支持。提前致谢!
【问题讨论】:
-
maven-assembly-plugin 似乎是错误的选择,因为 Spring Boot 将无法检测到 jar。相反,正如 Mathias 指出的那样,需要 spring-boot-maven-plugin。
标签: maven spring-boot executable-jar