How to add extra dir to CLASSPATH at spring-boot
Spring-boot has three built-in launchers as real main classes, JarLauncher, WarLauncher and PropertiesLauncher, which could be used to call executable. These launchers set the path to load resources and classes.
Only PropertiesLauncher could be use dir outside the jar file. To add an extra dir 'EXTRA' to classpath:
1. for maven, add the following fragment
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
</configuration>
</plugin>
2. Use loader.path when execute the jar
java -Dloader.path="lib/,config/,EXTRA/" -jar the.jar
Then, for example, ClassPathResource("1.properties") could get 1.properties from EXTRA dir.
1 comment:
Thanks so much! This worked! 谢谢!
Post a Comment