添加注解:
@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
来源: http://www.bubuko.com/infodetail-2928390.html