Spring Boot JAR不包含src文件夹中的类

时间:2017-05-23 11:40:56

标签: java spring maven spring-boot spring-boot-maven-plugin

我正在升级项目的Spring版本,我注意到当我将文件作为Archive打开时,src /文件夹不会显示为类。相反,我找到的是一个/ org文件夹,我找到了Spring。

实际上看起来像这样, enter image description here

奇怪的是,我们在Spring 1.3.x.RELEASE

之前很好地获得了类(正如您在JAR中所期望的那样)。

我的pom.xml看起来像这样,

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.3.RELEASE</version>
</parent>
<groupId>spring.mvn</groupId>
<artifactId>dummySpringMvn</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
    <java.version>1.8</java.version>

    <mvn.compiler.version>3.3</mvn.compiler.version>

    <spring.framework.version>4.3.8.RELEASE</spring.framework.version>
    <start-class>dummySpringMvn.main.Main</start-class>

</properties>

<packaging>jar</packaging>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>${start-class}</mainClass>
                <layout>ZIP</layout>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:3)

我在BOOT-INF文件夹中找到了我的课程!

enter image description here

我感谢文章https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html

此外,我升级的项目是另一个项目的库。我能够将JAR的文件夹保持为常规创建JAR而不调用spring-boot-maven-plugin

相关问题