maven - Spring 启动: how do I create a self-contained executable jar?

标签 maven spring-boot executable-jar

我是 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 - Spring 启动: how do I create a self-contained executable jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34037388/

相关文章:

java - 使用java和maven打开文件

mysql - 如何使用虚拟实体数据预填充数据库?

java - 无法连接到 spring cloud consul(无法设置主机/端口)

java - 如何将所有 .class 文件从 .jar 文件转换为 .java 文件

java - crontab 不运行 java

maven - 为什么 maven-war-plugin 会生成 JAR 而不是 WAR?

maven - 使用 Tycho 构建产品时出现 "Icon(s) not replaced"错误

java - 无法从 START_OBJECT token 中反序列化 `java.lang.String` 的实例

spring-boot - 如何在 Spring Boot 测试中模拟 BindingResult

java - 如何将 Java 应用程序导出为可运行的?