В моем приложении SpringBoot
есть служба, определенная как:
@Service
public class JdbcService {
@Autowired
JdbcTemplate jdbcTemplate;
@Autowired
public DataSource myDatabase;
public void run() {
System.out.println(">>run()");
jdbcTemplate.setDataSource(stagingDatabase);
jdbcTemplate.execute("INSERT SAMPLETABLE1 (STRING1, STRING2) VALUES ('TEST1', 'TEST2)");
System.out.println("<<run()");
}
}
Я получаю:
Description:
Field jdbcTemplate in com.myproject.services.JdbcService required a bean of type 'org.springframework.jdbc.core.JdbcTemplate' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.jdbc.core.JdbcTemplate' in your configuration.
Когда я добавляю @ComponentScan(basePackages="com.myproject")
к моему SpringBootApplication, определенному в этом пакете, я также получаю его.
build.gradle включает в себя:
compile("org.springframework.boot:spring-boot-starter-jdbc")
Есть идеи?