본문 바로가기

개발/스프링6

@Autowired vs @Resource (메소드에 한해서..) Use @Autowired or @Inject. This limitation is covered in the Spring reference documentation: Fine-tuning annotation-based autowiring with qualifiers:@Autowired applies to fields, constructors, and multi-argument methods, allowing for narrowing through qualifier annotations at the parameter level. By contrast, @Resource is supported only for fields and bean property setter methods with a single a.. 2016. 10. 27.
JavaConfig 예제 (dataSource) package com.terry.boardprj.common; import javax.sql.DataSource; import org.apache.commons.dbcp.BasicDataSource;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration; @Configurationpublic class BoardConfig {         @Bean(destroyMethod="close")    public DataSource dataSource(){        BasicDataSour.. 2016. 10. 27.
@Autowired @Inject @Resource @Autowired, @Resource, @Inject의 차이 [출처] [Spring] @Autowired, @Resource, @Inject의 차이|작성자 심해펭귄이번에 소개하는 세가지 어노테이션 @Autowired, @Resource,@Inject은 모두 의존관계를 자동으로 연결해주는 기능을 가진 어노테이션입니다. 다만 조금씩의 차이가 있습니다. @Autowired @Inject@Resource 범용스프링 전용자바에서 지원 자바에서 지원 연결방식타입에 맞춰서 연결 타입에 맞춰서 연결 이름으로 연결 자세한 설명을 하자면, @Inject와 @Resource는 JSR에 실려있는 자바 기존의 어노테이션입니다. 반면 @Autowired의 경우에는 스프링에서 등장한 어노테이션입니다. 따라서 스프링 이외에서는 사.. 2016. 10. 27.
Spring doesn't evaluate @Value annotation from properties 일단, 핵심은 Note that actual processing of the @Value annotation is performed by a BeanPostProcessor 결론적으로 @Value 가 적용된 변수를 사용하고 싶다면,@PostConstruct 태그를 붙인 메소드안에서 사용하면 된다. 태그 이름에서 알 수 있듯이,객체가 생성되어지고 난 후에 초기화 작업을 할 때 위 태그를 붙여서 사용하면된다. 출처 : http://stackoverflow.com/questions/11890544/spring-value-annotation-in-controller-class-not-evaluating-to-value-inside-pro 2016. 10. 14.