[英]How to read application.properties value inside the constructor in spring boot?
[英]Spring Boot passing value / using method inside the application.properties
例如:
我有一个名为Path.java的类
在Path.java中,我有getter方法“getPort()”,返回int 8080
在application.properties中,我想使用server.port =“getPort()”
怎么样?
我想外化数据源。 我已经有一个类从外部.txt文件中获取信息。 我需要在application.properties中使用这个类。
比如,spring.datasource.url = ?? getURL()??
Path.java
如何在Path.java
获取port
。 然后只需重用该信息。 无法在属性文件中调用方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.