Получение ошибки ниже при запуске сервера.
org.springframework.beans.factory.BeanCreationException: Ошибка создания bean-компонента с именем "kuttyJavaController": не удалось выполнить инъекцию автоуведомленных зависимостей; Вложенное исключение - org.springframework.beans.factory.BeanCreationException: Не удалось создать поле autwire: private org.springframework.jdbc.core.JdbcTemplate com.service.KuttyJavaController.jdbcoriensb2c; Вложенное исключение - это org.springframework.beans.factory.NoSuchBeanDefinitionException: не существует определяющего компонента типа [org.springframework.jdbc.core.JdbcTemplate], найденного для зависимости: ожидается как минимум 1 компонент, который квалифицируется как кандидат на автоподключение для этой зависимости. Аннотации зависимостей: {@org.springframework.beans.factory.annotation.Autowired(required = true)}
Bean.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd ">
<bean id="oriensb2c"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="aa" />
<property name="url" value="jdbc:mysql://localhost:3306/aa" />
<property name="password" value="aa" />
</bean>
<bean id="oriensb2b"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="bb" />
<property name="url" value="jdbc:mysql://localhost:3306/bb" />
<property name="password" value="bb" />
</bean>
<bean id="nstoreb2c"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="cc" />
<property name="url" value="jdbc:mysql://localhost:3306/cc" />
<property name="password" value="cc" />
</bean>
<bean id="nstoreb2b"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="username" value="dd" />
<property name="url" value="jdbc:mysql://localhost:3306/dd" />
<property name="password" value="dd" />
</bean>
<!-- Definition for JDBCTemplate bean -->
<bean id="jdbcoriensb2c" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="oriensb2c"></property>
</bean>
<bean id="jdbcoriensb2b" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="oriensb2b"></property>
</bean>
<bean id="jdbcnstoreb2c" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="nstoreb2c"></property>
</bean>
<bean id="jdbcnstoreb2b" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="nstoreb2b"></property>
</bean>
<bean id="kuttyJavaController" class="com.service.KuttyJavaController">
<property name="jdbcoriensb2c" ref="jdbcoriensb2c"></property>
<property name="jdbcoriensb2b" ref="jdbcoriensb2b"></property>
<property name="jdbcnstoreb2c" ref="jdbcnstoreb2c"></property>
<property name="jdbcnstoreb2b" ref="jdbcnstoreb2b"></property>
</bean>
</beans>
контроллер:
@Controller
public class KuttyJavaController {
//Oriens B2c
private JdbcTemplate jdbcoriensb2c;
//Oriens B2b
private JdbcTemplate jdbcoriensb2b;
//Nstore B2c
private JdbcTemplate jdbcnstoreb2c;
//Nstore B2b
private JdbcTemplate jdbcnstoreb2b;
public void setJdbcoriensb2c(JdbcTemplate jdbcoriensb2c) {
this.jdbcoriensb2c = jdbcoriensb2c;
}
public void setJdbcoriensb2b(JdbcTemplate jdbcoriensb2b) {
this.jdbcoriensb2b = jdbcoriensb2b;
}
public void setJdbcnstoreb2c(JdbcTemplate jdbcnstoreb2c) {
this.jdbcnstoreb2c = jdbcnstoreb2c;
}
public void setJdbcnstoreb2b(JdbcTemplate jdbcnstoreb2b) {
this.jdbcnstoreb2b = jdbcnstoreb2b;
}
Названия ваших бобов не совпадают. Например, у вас есть следующее:
<bean id="nstoreb2btemplate" name="nstoreb2btemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="nstoreb2b"></property>
</bean>
Тем не менее, вы вызываете его, используя:
//Nstore B2b
private JdbcTemplate jdbcnstoreb2b;
Это должно быть (конечно, также в случае с верблюдом):
//Nstore B2b
private JdbcTemplate nstoreb2btemplate;