0

I have a problem with inject properties in my @Component class

@Configuration
@ComponentScan("my.package.*")
@PropertySource("classpath:setting.properties")
public class PropertiesWithJavaConfig {

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
  return new PropertySourcesPlaceholderConfigurer();
  }
}

Component class

@Component
public class Why {
@Value("${sc.ws.user}")
private  String user;

public  void  testProperties(){
    System.out.println(user);
  }
}

Initial class for testing

Why w = new Why();
w.testProperties();

Thanks for help

luprogrammer
  • 155
  • 3
  • 12

0 Answers0