I've a config.properties files under src/main/java/configs/config.properties which contains the following profile:
<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>
my config.properties file contains
no_of_rows = ${no_of_rows} no_of_files = ${no_of_files}
I'm using the following maven command to pass these properties via the command line
mvn exec:java -Dexec.mainClass="com.mycompany.project.App" -Dno_of_rows=4 -Dno_of_files=3
but it results into
[ERROR] Resolving expression: '${no_of_files}': Detected the following recursive expression cycle in 'no_of_files': [no_of_files] @
I've looked into other similar answers on stackoverflow but I think I'm still not getting the right way.
I need this to run the project using a bamboo job.
You don't need any Maven funkiness to do this:
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");
}
}
The config.properties and maven profile are not needed at all.
If you really want to generate values into a properties file then that is a more complicated answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.