小编pcl*_*ves的帖子

如何使用环境变量激活 Maven 配置文件?

出于某种原因,我必须使用环境变量而不是将系统属性传递给 mvn 命令。因此,我使用 ${env.PROFILE} 作为属性名称, pom.xml 中的配置文件设置显示如下:

    <profiles>
        <profile>
            <id>dev</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property>
                    <name>${env.PROFILE}</name>
                    <value>dev</value>
                </property>
            </activation>
            <properties>
                <profile.assembly.suffix></profile.assembly.suffix>
            </properties>
        </profile>
        <profile>
            <id>online</id>
            <activation>
                <property>
                    <name>${env.PROFILE}</name>
                    <value>online</value>
                </property>
            </activation>
            <properties>
                <profile.assembly.suffix>-online</profile.assembly.suffix>
            </properties>
        </profile>
    </profiles>
Run Code Online (Sandbox Code Playgroud)

然后,我尝试将配置文件激活为在线,但失败了,命令行显示如下:

E:\Tetris\src\1_Branches\rtm_tetris_zhugan\Server\LobbyServer>set PROFILE=online
E:\Tetris\src\1_Branches\rtm_tetris_zhugan\Server\LobbyServer>echo %PROFILE%
online

E:\Tetris\src\1_Branches\rtm_tetris_zhugan\Server\LobbyServer>mvn help:active-profiles
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for Fusion:LobbyServer:jar:1.0
[WARNING] 'dependencies.dependency.systemPath' for Fusion:Fusion-Core:jar should not point at files within the project directory, ${project.basedir}/../libs/Fusion-Core-2.0.jar will be unresolvable by dependent projects @ …
Run Code Online (Sandbox Code Playgroud)

maven maven-profiles

6
推荐指数
2
解决办法
6249
查看次数

标签 统计

maven ×1

maven-profiles ×1