通过maven命令行传递java属性文件密钥
我在src/main/java/configs/config.properties下有一个config.properties文件,其中包含以下配置文件:通过maven命令行传递java属性文件密钥,java,maven,command-line,bamboo,properties-file,Java,Maven,Command Line,Bamboo,Properties File,我在src/main/java/configs/config.properties下有一个config.properties文件,其中包含以下配置文件: <profiles> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<no_of_files>${no_of_files}</no_of_files>
<no_of_rows>${no_of_rows}</no_of_rows>
</properties>
</profile>
</profiles>
但结果是
[ERROR] Resolving expression: '${no_of_files}': Detected the following recursive expression cycle in 'no_of_files': [no_of_files] @
我已经研究了stackoverflow的其他类似答案,但我认为我仍然没有找到正确的方法
我需要这个来运行使用竹作业的项目。您不需要任何Maven的趣味性来执行此操作:
public class App {
public static void main(String ...args) {
// Load value from -Dno_of_files=
Integer noOfFiles = Integer.getInteger("no_of_files");
// Load value from -Dno_of_rows=
Integer noOfRows = Integer.getInteger("no_of_rows");
}
}
根本不需要config.properties和maven概要文件
如果您真的想在属性文件中生成值,那么这是一个更复杂的答案
public class App {
public static void main(String ...args) {
// Load value from -Dno_of_files=
Integer noOfFiles = Integer.getInteger("no_of_files");
// Load value from -Dno_of_rows=
Integer noOfRows = Integer.getInteger("no_of_rows");
}
}