在服务器启动期间出现以下错误。
org.springframework.beans.factory.beancreationexception:创建名为“kuttyjavacontroller”的bean时出错:自动连线依赖项的注入失败;嵌套异常为org.springframework.beans.factory.beancreationexception:could not autowire字段:private org.springframework.jdbc.core.jdbctemplate com.service.kuttyjavacontroller.jdbcoriensb2c;嵌套的异常为org.springframework.beans.factory.nosuchbeandefinitionexception:找不到符合依赖关系类型[org.springframework.jdbc.core.jdbctemplate]的合格bean:至少需要1个符合此依赖关系的autowire候选bean。依赖项注解:{@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;
}
1条答案
按热度按时间c0vxltue1#
你的豆子名字不匹配。例如,定义了以下内容:
然而,你称之为:
这应该是(当然,在 Camel 的情况下也是这样):