Java遇到的几个注解

1.解决注释失败问题(@PostConstruct)

@Resource
private ChatMessageMapper cmm;
@Resource
private UserBasicMapper ubm;
@Resource
private UserBasePhoneMapper ubpm;
@Resource
private ProjectMemberService pms;

private static ProjectMemberService projectMemberService;

private static ChatMessageMapper chatMessageMapper;

private static UserBasicMapper userBasicMapper;

private static UserBasePhoneMapper userBasePhoneMapper;

/**
 * 在注入之后调用,解决注释失败问题
 */
@PostConstruct
public void init0(){
    chatMessageMapper = cmm;
    userBasicMapper = ubm;
    userBasePhoneMapper = ubpm;
    projectMemberService =pms;
}

2可以使用@Value注解读取数据,如何配置

//使用@Value注解(@Value("${spring.redis.timeOut:10000}"))
@Component
@PropertySource("classpath:application.yml")
或者
@Configuration

你可能感兴趣的:(java学习日常)