자바 메인클래스에서 @Autowired 사용 (스프링부트)

  • xixixaxa
    (OOooOOoo)
  • xixixaxa's Avatar 이 글의 작성자
  • Offline
  • Newbie
  • Newbie
더보기
21 Oct 2022 09:35 - 21 Oct 2022 09:35 #31959 작성자: xixixaxa
xixixaxa 님의 글: 자바 메인클래스에서 @Autowired 사용 (스프링부트)
다음과 같은 방식으로 처리함

public class TestApplication implements ApplicationRunner {
	@Autowired
	ConnectionPool connectionPool;
	
	public static void main(String[] args) {		
		SpringApplication.run(TestApplication.class, args);
										
		System.out.println("TestApplication");
	}
	
    @Override
    public void run(ApplicationArguments args) throws Exception {
		connectionPool.initTarget();
		ExchangeLocalCache.initCache();
    }
}
Time to create page: 0.054 seconds
Powered by Kunena Forum