Spring Boot 2.2.1 在 Build 时创建两个 jar

标签 spring spring-boot maven maven-3

这个问题在这里已经有了答案:





Why spring boot generates jar or war file with .original extension?

(2 个回答)


1年前关闭。




我正在处理 Spring boot版本2.2.1.RELEASE .在构建我的项目时,将创建两个 jar 类型 executable jar fileoriginal file如下所示

enter image description here

这样做的原因是

Maven first builds my project and packages my classes and resources into a jar (${artifactId}.jar) file.

Then, repackaging happens. In this goal, all the dependencies mentioned in the pom.xml are packaged inside a new WAR (${artifactId}.jar) and the previously generated war is renamed to ${artifactId}.jar.original.



xml文件
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>  
              <executions>
                 <execution>
                     <goals>
                         <goal>repackage</goal>
                     </goals>
                 </execution>
             </executions>         
            <configuration>    
                <mainClass>com.data.MainService</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

我们如何避免创建ORIGINAL File输入jar文件。

Maven 中是否有任何禁用/排除技术可用。

我也试过关注 <build>
<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>                         
                <configuration>    
                    <mainClass>com.data.MainService</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

最佳答案

根据实现 jar.original 是预期的。没什么可担心的。

重新打包会创建新的 jar 文件并将旧的文件重命名为 jar.original

https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins.html#build-tool-plugins-repackage-implementation

关于Spring Boot 2.2.1 在 Build 时创建两个 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59098178/

相关文章:

eclipse - 防止 Eclipse 从 Maven 目标文件夹定位/链接文件

java - Spring Security - 连续登录2次行为

java - Spring 拦截

java - Spring 启动 org.springframework.web.util.NestedServletException : Request processing failed

java - DOCKER 错误 : Pull access denied for coffeeteareadb, 存储库不存在或可能需要 'docker login'

java - Spring boot with testcontainers - 如何防止上下文重新加载时数据库初始化

spring - 如何使用 Mockito 在 Spring 中模拟 Autowiring 的 @Value 字段?

java - 从不同的 HTTP 请求访问 Spring bean

maven - Maven单独的单元测试和集成测试

java - 使用maven将storm和cassandra打包成可执行jar