0
我是apache Maven中的新手。當我嘗試從屬性文件中讀取值時,它不會選取值。我已經在SO中看到過所有以前提過的問題。但沒有運氣。這是我的財產文件。Maven:無法從Proprties獲得屬性值文件
nameofmayil=mayilsamy
這是的pom.xml
<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.mycompany.mayil</groupId>
<artifactId>mayil-app</artifactId>
<version>1.0.1</version>
<packaging>jar</packaging>
<name>mayil-app</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
<scm>
<connection>scm:svn:http://127.0.0.1/svn/my-project</connection>
<developerConnection>scm:svn:https://127.0.0.1/svn/my-project</developerConnection>
<tag>HEAD</tag>
<url>http://127.0.0.1/websvn/my-project</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<!-- Associate the read-project-properties goal with the initialize phase, to read the properties file. -->
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/buildNumber.properties</file>
<file>${basedir}/mayil.properties</file>
</files>
<quite>false</quite>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Displaying value of properties</echo>
<echo>${nameofmayil}</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
屬性文件被加載正確,我與檢查。
您可以顯示生成日誌嗎?你使用什麼命令來運行構建? – Dmitry 2013-05-13 11:29:12
$ mvn install ... – Arung 2013-05-13 11:34:45
好的,你運行'mvn install'會得到什麼輸出?請將此信息添加到問題中。 – Dmitry 2013-05-13 11:41:44