spring-guides / gs-relational-data-access

Accessing Relational Data using JDBC with Spring :: Learn how to access relational data with Spring.

Home Page:https://spring.io/guides/gs/relational-data-access/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autowired issue

fsanna13 opened this issue · comments

Using IntelliJ, the Autowired annotation for the jdbcTemplate variable is labeled as an issue.

...
public static void main(String[] args) {
	SpringApplication.run(SpringjdbcApplication.class, args);
}

@Autowired //Field injection is not recommended
JdbcTemplate jdbcTemplate;

@Override
public void run(String... args) throws Exception {
        log.info("Creating tables");
...

It says that "Field injection is not recommended". How to solve this?

I assigned Greg Turnquist to this one, as a way to get a good answer to your question. Once Greg does so, we can close it.