pom.xml配置

<profiles>
	<profile>
		<id>dev</id>
			<properties>
				<token>dev</token>
			</properties>
        <!-- 默认打包参数 -->
                    <activation>
				<activeByDefault>true</activeByDefault>
			</activation>
	</profile>
	<profile>
		<id>test</id>
			<properties>
				<token>test</token>
			</properties>
	</profile>
</profiles>

 <build>
<!-- 开启资源配置--> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>

  

test.properties

token=${token}

  *.java // 获取参数的java类

public class TokenTestPom {
	
	private static ResourceBundle resource = ResourceBundle.getBundle("token");
	
	public static final String TOKEN=  resource.getString("token");
	

}

  

项目打包命令:

 mvn install   -Ptest

 

相关文章:

  • 2022-01-04
  • 2021-11-27
  • 2021-05-11
  • 2021-06-20
  • 2021-09-05
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2021-08-30
  • 2021-08-09
  • 2022-01-07
  • 2021-04-10
  • 2022-12-23
相关资源
相似解决方案