如何快速学习:[1]Swift编程语言,Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Ojective-C*共同运行于MacOS和iOS平台,用于搭建基于苹果平台的应用程......
2023-03-17 302 编程语言
Spring的p标签是property的short cut,使用起来很方面
下面就聊聊遇到的一个坑
在网上下了个源码,导入到工程中后
然后就报了下面的错
Attribute p:host-nameis not allowed here
当时考虑到,是不是因为p标签的schema没有导入导致。
看了下doc
XML shortcut with the p-namespace
The p-namespace enables you to use thebeanelement's attributes, instead of nestedproperty/>elements, to describe your property values and/or collaborating beans.
Spring 2.0 and later supports extensible configuration formatswith namespaces, which are based on an XML Schema definition.
在beans节点中添加p标签的schema试试
xmlns:p="http://www.springframework.org/schema/p"
不过,貌似没有什么用
会不会是因为属性名和class中不一致,不过不应该啊。
看看呗:
private String hostName = "localhost";
private JedisPoolConfig poolConfig = new JedisPoolConfig();
bean中
bean id="connectionFactory" 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"/>
果然是。改:
bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:hostName="${redis.host}" p:port="${redis.port}" p:password="${redis.pass}"
p:poolConfig-ref="poolConfig"/>
p标签的事解决了。Spring的这个配置文件,还在漂红。
好吧。
把刚才添加的p标签的定义删除掉,就可以了
以上方法由办公区教程网编辑摘抄自百度经验可供大家参考!
标签: 编程语言
相关文章
如何快速学习:[1]Swift编程语言,Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Ojective-C*共同运行于MacOS和iOS平台,用于搭建基于苹果平台的应用程......
2023-03-17 302 编程语言
web图表开发工具FineReport:[11]连续分组,数据库表数据是按照时间先后录入的,查询的时候希望按照时间先后,某个字段连续相同的话就合并起来显示,这样的报表可以通过相邻连续分组来实现。......
2023-03-17 525 编程语言