代码之家  ›  专栏  ›  技术社区  ›  jayko03

war文件不包含版本号

  •  0
  • jayko03  · 技术社区  · 5 年前

    我在pom中有这样的设置,并尝试运行maven目标(主要是 mvn clean install ).我希望它能创造 war 文件看起来像, project-1.0.1-SNAPSHOT.war .但它总是创造 project.war .如何创建文件名中包含版本信息的war文件?

    <?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>com.xxxxxxx.xxxxxx</groupId>
        <artifactId>xxxxxxxx</artifactId>
        <packaging>war</packaging>
        <version>1.0.1-SNAPSHOT</version>
        <name>${project.artifactId}</name>
    
        <parent>
            <artifactId>war-common-pom</artifactId>
            <groupId>com.xxxxx.xxxxxxxxx.pom</groupId>
            <version>4.0.0</version>
        </parent>
    
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <spring.version>4.3.18.RELEASE</spring.version>
        </properties>
        <dependencies>
            <!-- Spring framework -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring.version}</version>
                <scope>compile</scope>
            </dependency>
    
        </dependencies>
        <build>
            <finalName></finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                        <warSourceExcludes>node_modules/**</warSourceExcludes>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>1.6</version>
                    <configuration>
                        <nodeVersion>v12.16.1</nodeVersion>
                        <npmVersion>6.13.4</npmVersion>
                        <workingDirectory>src/main/webapp/frontend</workingDirectory>
    
                    </configuration>
    
                    <executions>
                        <execution>
                            <id>Install node and npm locally to the project</id>
                            <goals>
                                <goal>install-node-and-npm</goal>
                            </goals>
                        </execution>
    
                        <execution>
                            <id>npm install</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>
                        </execution>
    
                        <execution>
                            <id>Build frontend</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>
                            <configuration>
                                <arguments>run build</arguments>
                            </configuration>
                        </execution>
    
                    </executions>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>Copy frontend build to target</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${basedir}/target/classes/resources</outputDirectory>
                                <resources>
                                    <resource>
                                        <directory>${basedir}/src/main/webapp/frontend/build</directory>
                                        <filtering>true</filtering>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    
    
            </plugins>
        </build>
    
    </project>
    
    0 回复  |  直到 5 年前