添加注解:
@PropertySource(value={"classpath:venus.properties"}) 示例:
import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Service; import java.util.Map; @Service @PropertySource(value={"classpath:venus.properties"}) public class SyncService { @Value("${default.pwd}") private String defaultPwd; @Value("${default.role}") private String defaultRole; @Value("${default.area}") private String defaultArea; //venus获取用户的默认分页大小 private static int pageSize = 1000; public void venusUserSync(Map<String, Object> params) { } }
然后venus.properties中示例如下
#默认密码,登入从单点走,密码无用default.pwd=123456#多个角色以,隔开default.role=1#多个地区,隔开default.area=350500
原文地址:https://www.cnblogs.com/chenmz1995/p/10296726.html
时间: 2024-10-10 11:19:53