The prefix "p" for attribute "p:host-name" associated with an element type "bean

 <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"  

        p:host-name="${redis.host}" p:port="${redis.port}" p:password="${redis.pass}"  p:pool-config-ref="poolConfig"/>  

在Spring配置文件中配置数据源使用SpEL、p:driverClass等元素时不小心会出现下面错误

The prefix "p" for attribute "p:host-name" associated with an element type "bean" is not bound.

这是因为在使用XML Schema作为配置文件的语义约束时,没有添加下面这条语句
<?xml version="1.0"encoding="UTF-8"?> 
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:context="http://www.springframework.org/schema/context"xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:p="http://www.springframework.org/schema/p"

猜你喜欢

转载自wuhen639.iteye.com/blog/2210688
今日推荐