【问题标题】:Having application as standalone as well as dependency in Spring Boot 1.5在 Spring Boot 1.5 中具有独立的应用程序和依赖项
【发布时间】:2017-05-10 01:58:28
【问题描述】:

我有一个 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 下。

那么我怎样才能拥有一个项目独立应用程序以及将其作为另一个项目的依赖项?

【问题讨论】:

    标签: java maven spring-boot


    【解决方案1】:

    似乎是 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-07
      • 2016-10-23
      • 1970-01-01
      • 2016-07-04
      • 1970-01-01
      • 1970-01-01
      • 2019-07-14
      相关资源
      最近更新 更多