Maven pom.xml <version> </version>

时间:2016-07-12 09:13:29

标签: eclipse maven java-ee

  <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>org.jboss.tools</groupId>
            <artifactId>example</artifactId>
            <packaging>war</packaging>
            <version>0.0.1-SNAPSHOT</version>
            <name>example</name>
        <properties>
                <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            </properties>
<build>
        <finalName>example</finalName>
            <pluginManagement>
                <plugins>
                    <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>
                            <compilerArguments>
                                <endorseddirs>${endorsed.dir}</endorseddirs>
                            </compilerArguments>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.6</version>
                        <configuration>
                        <warName>example.war</warName>
                            <failOnMissingWebXml>true</failOnMissingWebXml>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.10</version>
                        <executions>
                            <execution>
                                <phase>validate</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${endorsed.dir}</outputDirectory>
                                    <silent>true</silent>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>javax</groupId>
                                            <artifactId>javaee-endorsed-api</artifactId>
                                            <version>7.0</version>
                                            <type>jar</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>

我正在为我的项目使用上面的代码配置。但是当我通过eclipse构建我的项目时,它将项目部署为:example-0.0.1-SNAPSHOT。 我不明白为什么-0.0.1-SNAPSHOT追加到我的项目名称后? 我更新了我的版本。但我仍然得到同样的错误。

1 个答案:

答案 0 :(得分:6)

这是<build> <directory>${project.basedir}/target</directory> <outputDirectory>${project.build.directory}/classes</outputDirectory> <finalName>${project.artifactId}-${project.version}</finalName> 属性定义的默认名称。如果您没有定义此属性,则defaut值为:

<pluginManagement>

文档:Jaxb - Overriding the XMLElement name attribute

修改

此外,在这个简单的情况下,您不应该使用pom.xml。 因此,在这种情况下,您应该按照以下方式组织<project> <build> <finalName>...</finalName> <plugins>...</plugins> </build> </project>

<form action="" class="update-pages" method="GET">
    <input type="hidden" value="about" id="getLoc" name="about" />
    <textarea name="txt" rows="20">

    </textarea>
    <br />
    <input type="submit" class="btn btn-primary btn-lg" value="UPDATE" name="sbmt_change" />