我有一个Maven2项目,我需要在属性文件中添加当前版本和当前日期.
对于当前版本,我已经使用过${project.version},它可以正常工作.
我的问题是如何在我的属性文件中设置当前日期(即Maven2完成构建的日期):
client.version=Version ${project.version}
client.build=???
Run Code Online (Sandbox Code Playgroud)
(另外,如果我可以指定日期的格式,那将非常棒)
Java和Maven的新手,但我试图让Maven处理数据库连接属性,这样我就可以让maven构建在dev/stage/prod环境之间进行更改,我遇到了过滤和资源问题.不知道我在这里做错了什么.
POM文件:
<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.comapny</groupId>
<artifactId>reporting</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>reporting</name>
<url>http://maven.apache.org</url>
<properties>
<db.jdbcUrl>jdbc:aURL</db.jdbcUrl>
<db.jdbcUn>aUser</db.jdbcUn>
<db.jdbcPw>aPassword</db.jdbcPw>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springframework.version>4.2.3.RELEASE</springframework.version>
<springframework.jdbc.version>4.1.4.RELEASE</springframework.jdbc.version>
<hadoop.version>2.7.1.2.3.4.2-1</hadoop.version>
<hbase.version>1.1.2.2.3.4.2-1</hbase.version>
<phoenix.version>4.4.0.2.3.4.2-1</phoenix.version>
<junit.version>4.12</junit.version>
<mail.version>1.4.3</mail.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>
<repositories>
<repository>
<id>github-releases</id>
<url>http://oss.sonatype.org/content/repositories/github-releases/</url>
</repository>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
<repository>
<id>hortonworks</id>
<url>http://repo.hortonworks.com/content/repositories/releases/</url>
</repository>
<repository>
<id>twitter4j</id>
<url>http://twitter4j.org/maven2</url>
</repository>
</repositories>
<dependencies>
<!-- <dependency> <groupId>jdk.tools</groupId> <artifactId>jdk.tools</artifactId>
<version>1.7.0_05</version> <scope>system</scope> <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <version>1.2.3.RELEASE</version> -->
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
</dependency> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Eclipse Luna调试我的Maven webapp项目以在Tomcat 8中启动它.不幸的是,在尝试将其部署到Tomcat时,资源过滤期间的构建时间戳没有得到解决.Eclipse构建的WAR文件已解决,但它部署到Tomcat(通过"在服务器上运行"选项)不会.
在我的pom.xml中,我得到了:
<properties>
<timestamp>${maven.build.timestamp}</timestamp>
</properties>
<build>
<finalName>rapid-installer</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
Run Code Online (Sandbox Code Playgroud)
在一个属性文件中,我有
build.date=${timestamp}
Run Code Online (Sandbox Code Playgroud)