java - 在 Spring Boot 1.5 中使应用程序既独立又依赖

标签 java maven spring-boot

我有一个 Spring Boot 应用程序(应用程序 A),我将其部署为独立的 fat jar。但我还有另一个依赖于应用程序 A 的 Spring Boot 应用程序(应用程序 B)。现在,当我尝试将应用程序 A 中的一些类导入到应用程序 B 中时,出现找不到包异常。但是,Intellij/Eclipse 等 IDE 能够正确找到该包。当我使用 Spring Boot 1.3.x 时,这曾经有效。然而,升级到1.5.x后,它开始失败。

在检查实际的 jar 文件时,我意识到在 Spring Boot 1.3.3 中,所有类都位于主包下。但是,对于 Spring Boot 1.5.x,它们位于 BOOT-INF 文件夹下。在 META-INF/Manifest.MF 文件中,我们有指向 BOOT-INF 文件夹的属性。因此,当我尝试导入类时,它无法找到包,因为它们位于 BOOT-INF 下。

那么我还能如何拥有一个项目独立应用程序并将其作为另一个项目的依赖项呢?

最佳答案

似乎是 Spring Boot 1.4.x ( https://github.com/spring-projects/spring-boot/issues/6792#issuecomment-243564648 ) 的一个已知问题。更新应用程序 A 中的 pom 文件以进行以下修复:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <classifier>exec</classifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

关于java - 在 Spring Boot 1.5 中使应用程序既独立又依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43882447/

相关文章:

java - iText PDF 创建错误

java - 使用 Selenium Webdriver 控制 Chrome Devtools

java - 如何与 Maven 一起运行 xml 配置驱动和无 xml Spring Web 应用程序?

java - mvn 发布 :prepare in spring boot 时无法将文件提交到 github

java - JSON 解析错误 : Can not deserialize instance of java. util.ArrayList 超出 START_OBJECT token

spring-boot - Elasticsearch 分析器在通过 Spring Data 创建时工作,但在直接从 Postman/curl 创建时失败

java - 递归获取驻留在 AVL 树中的数字的计数

java - 代号一个最新的字体构建问题?

maven-2 - 如何在一个子模块中覆盖 maven-release-plugin 配置

java - Spring Boot Rest 中的 Jersey 名称绑定(bind)技术