spring boot中static字段用@Value注解不进去解决方案
2018-02-01 17:44
337 查看
使用@Value注解static字段,会发现注解不上去,所以就有了下面这段代码。
package com.demo.test.utils; import java.util.Random; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class ThreadPoolUtil { private static int corePoolSize; @SuppressWarnings("static-access") @Value("${threadpool.corepoolsize}") public void setCorePoolSize(int corePoolSize) { this.corePoolSize = corePoolSize; } }
相关文章推荐
- Spring Boot集成JPA的Column注解命名字段无效的问题
- Spring Boot集成JPA的Column注解命名字段无效的问题
- static 字段 使用@Value 注解获取配置文件中的值
- (15)spring boot使用@Value,@PropertySource注解使用
- 在Spring-boot中,为@Value注解添加从数据库读取properties支持
- springboot中用注解配置过滤器并配置多个过滤路径
- SpringBoot中的注解使用
- 转-spring-boot 注解配置mybatis+druid(新手上路)-http://blog.csdn.net/sinat_36203615/article/details/53759935
- spring boot 拦截器的实现以及遇到的问题的解决方案
- springBoot注解的应用
- spring boot 计划任务,定时任务的注解的使用@Scheduled@EnableScheduling
- Springboot中使用RequiresPermissions注解无效
- spring整合shiro,且使用shiro注解出现代理异常解决方案
- Spring Boot系列之六 以注解方式整合MyBatis
- Spring Boot整合Kafka的简单用例(@KafkaListener注解)
- SpringBoot的注解:@SpringBootApplication注解 vs @EnableAutoConfiguration+@ComponentScan+@Configuration
- springboot->使用messagesSourcec处理字段验证抛出错误
- spring boot(七):springboot+mybatis多数据源最简解决方案
- spring boot: @Retention注解 @Documented 注解 @Inherited 注解
- Spring Boot注解