Java 在spring framework中创建名为在类路径资源[application context.xml]中定义的bean时出错

Java 在spring framework中创建名为在类路径资源[application context.xml]中定义的bean时出错,java,xml,spring,spring-mvc,Java,Xml,Spring,Spring Mvc,创建类路径中定义了名为“template”的bean时出错 资源[应用程序上下文.xml]:无法解析匹配 构造函数(提示:为简单 参数以避免类型歧义) 我不确定我在这里做错了什么来得到以上的错误?使用正确的变量名在属性文件中正确定义所有变量。要检查哪些内容?更改 <bean id="MyDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <propert

创建类路径中定义了名为“template”的bean时出错 资源[应用程序上下文.xml]:无法解析匹配 构造函数(提示:为简单 参数以避免类型歧义)

我不确定我在这里做错了什么来得到以上的错误?使用正确的变量名在属性文件中正确定义所有变量。要检查哪些内容?

更改

<bean id="MyDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="${url}"/>
        <property name="username" value="${username}"/>
        <property name="password" value="${password}"/>
    </bean>

    <bean id="template" class="org.springframework.jdbc.core.JdbcTemplate">
        <constructor-arg value="MyDataSource"/>
    </bean>


因为您不想注入要注入的
String

<bean id="template" class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg value="MyDataSource"/>
</bean>
<bean id="template" class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg ref="MyDataSource"/>
</bean>