![](/img/trans.png)
[英]How to invalidate browser cache in a web application built with angular7 and springboot
[英]Two JARs are built for SpringBoot application
我正在使用Spring Boot 1.4.1,並構建了一個非常簡單的應用程序。 當我使用以下pom.xml時,我看到使用maven構建了兩個JAR(abc.jar和abc-boot.jar)。 我如何避免構建abc.jar,因為它只是浪費了整個構建時間?
pom.xml粘貼在下面-
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>abc</groupId>
<artifactId>abc</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Need to avoid putting version in final jar's name -->
<finalName>abc</finalName>
<plugins>
<plugin>
<!-- Package as an executable jar -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>xyz.Application</mainClass>
<layout>ZIP</layout>
<classifier>boot</classifier>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
您將得到兩個jar,因為您已使用分類器配置了Spring Boot的Maven插件。 這意味着它產生的脂肪罐是在普通罐子旁邊創建的。
如果您想生產一個jar並將其變成一個胖jar,則應從插件配置中刪除<classifier>boot</classifier>
。
您將得到兩個工件,因為默認的程序集連接正在創建abc.jar,並且添加的spring-boot-maven-plugin將產生另一個名稱為abc-boot.jar的jar。
或者,您可以擺脫spring-boot-maven插件,但仍然能夠生成一個可執行jar。 這可以通過配置maven程序集插件來完成,如以下示例所示。
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
[...]
<archive>
<manifest>
<mainClass>org.sample.App</mainClass> //specify your spring-boot main class here.
</manifest>
</archive>
</configuration>
[...]
</plugin>
[...]
</project>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.