我想要一个代币“private.properties“我希望这个.properties文件只在运行时提供,我不想把这个文件放在我的.jar中
所以我把它排除在我的包装里:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/private.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
$ java -Dspring.config.additional-location=file:./config/private.properties -jar target/mytool-1.0.0-SNAPSHOT.jar
java.io.FileNotFoundException: class path resource [private.properties] cannot be opened because it does not exist
如果有空的“private.properties“不排除包装,它的作品。
只有一个外部的private.properties ?
下面是我在中声明文件位置的方法PrivateProperties.java :
@PropertySource("classpath:/private.properties")
我需要硬编码吗private.properties 工作地点?