在Spring框架中bean配置文件中constructor-arg标签中没有name元素?

版权声明:本文为changeyd原创文章,未经changeyd允许不得转载。谢谢合作 https://blog.csdn.net/qq_40223688/article/details/83307819

bean配置文件出现错误的依赖:

<beans
<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.xsd">

将以上依赖改成:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

就可在:bean标签下的constructor-arg标签中添加name属性了。

猜你喜欢

转载自blog.csdn.net/qq_40223688/article/details/83307819