Maven project.version - 使用子pom版本

时间:2016-01-29 20:39:06

标签: maven jsp maven-3 pom.xml

我需要在jsp上获取项目版本和构建日期。

以下是我需要使用该版本的pom:

   <parent>
        <groupId>a.b</groupId>
        <artifactId>c</artifactId>
        <version>0.1-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>a.b.c</groupId>
    <artifactId>c-uiWeb</artifactId>
    <version>1.2-SNAPSHOT</version>

JSP:

<br/><div align="right" style="display:none">Project Version:${project.version} - ${timestamp} </div><br/>

现在版本显示为&#34; 0.1-SNAPHOT&#34;。我需要它来显示&#34; 1.2-SNAPSHOT&#34;。我错过了什么?请帮忙

修改

项目结构:c-uiWeb

src -> main -> java

src --> main -> resources

src -> main -> webapp -> WEB-INF -> jsp

全程:

<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/maven-v4_0_0.xsd">

    <parent>
        <groupId>a.b</groupId>
        <artifactId>c</artifactId>
        <version>0.1-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>a.b.c</groupId>
    <artifactId>c-uiWeb</artifactId>
    <version>1.2-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>C- UI Web</name>
    <description>C- User Interface Web</description>
    <url>${site-root}/c/${project.artifactId}</url>

    <dependencies>
        <dependency>
            ...
        </dependency>           
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
                     <version>${maven-compiler-plugin-version}</version>
                     <configuration>
                         <source>1.6</source>
                         <target>1.6</target>
                     </configuration>
                 </plugin>
                 <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${maven-war-plugin-version}</version>
                    <configuration>
                        <webResources>
                            <resource>
                                <targetPath>WEB-INF/jsp</targetPath>
                                <directory>${basedir}/src/main/webapp/WEB-INF/jsp</directory>
                                <filtering>true</filtering>
                            </resource>
                        </webResources>
                    </configuration>
                 </plugin>                   
            </plugins>
        </pluginManagement>
    </build>
</project>

0 个答案:

没有答案