1

我正在尝试让 maven 从 ~/home/user/file.prop 之类的文件中加载我的属性。如果调用本地配置文件,有人可以告诉我如何更改以下 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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.uftwf</groupId>
    <artifactId>MavenJbossWebDemo</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>Maven and JBoss WebDemo Webapp</name>
    <url>http://maven.apache.org</url>


    <properties>
        <java-version>1.7</java-version>
    </properties>
    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <deploy.jboss.host>10.52.17.21</deploy.jboss.host>
                <deploy.jboss.user>admin</deploy.jboss.user>
                <deploy.jboss.password>redhat</deploy.jboss.password>
            </properties>
        </profile>

        <profile>
            <id>local</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <deploy.jboss.host>127.0.0.1</deploy.jboss.host>
                <deploy.jboss.user>xxx</deploy.jboss.user>
                <deploy.jboss.password>xxx</deploy.jboss.password>
            </properties>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>MavenJbossWebDemo</finalName>

        <plugins>
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <version>7.2.Final</version>
                <configuration>
                    <hostname>${deploy.jboss.host}</hostname>
                    <port>${deploy.jboss.port}</port>
                    <username>${deploy.jboss.user}</username>
                    <password>${deploy.jboss.password}</password>
                </configuration>
                <executions>
                    <execution>
                        <id>deploy-jar</id>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
4

1 回答 1

4

我认为 Properties Maven Plugin 可能会有所帮助。查看它的使用示例

于 2013-01-18T17:35:51.907 回答