java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2696字,纯文字阅读大概需要4分钟。
内容图文
![java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?](/upload/InfoBanner/zyjiaocheng/742/973c7bfc69a949f6a31201f63635f9e5.jpg)
有人可以告诉我在我的ApplicationContext中我必须使用bean:bean而不是bean以及如何修复它.
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/friends/**" access="hasRole('ROLE_USER')" />
<form-login login-page="/login.html"
default-target-url="/index.html" always-use-default-target="true"
authentication-failure-url="/login.html?authfailed=true" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource" />
</authentication-provider>
</authentication-manager>
<beans:bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="location" value="classpath:jdbc.properties" />
</beans:bean>
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<beans:property name="driverClassName" value="${database.driver}" />
<beans:property name="url" value="${database.url}" />
<beans:property name="username" value="${database.user}" />
<beans:property name="password" value="${database.password}" />
<beans:property name="initialSize" value="5" />
<beans:property name="maxActive" value="10" />
</beans:bean>
</beans:beans>
解决方法:
说明.基本上你在这里处理XML命名空间. Spring配置允许您使用来自不同命名空间的配置元素作为扩展基本bean命名空间配置的方法,使用方便的特定于域的配置,如上面的安全配置.
如果您的配置文件集中在其中一个扩展名称空间上 – 再次,让我们使用安全性作为示例 – 如果您将默认名称空间声明为扩展名称空间而不是标准bean名称空间,它可以清理该文件.那是什么
xmlns="http://www.springframework.org/schema/security"
确实 – 它使安全性成为默认命名空间,这意味着您不必使用sec:或security:作为前缀.
但是当您将安全性设置为默认值时,则在使用beans命名空间元素时必须明确.因此bean:前缀.
解.如果您更喜欢bean作为默认值,只需将默认命名空间更改为beans:
xmlns="http://www.springframework.org/schema/beans"
替代方案.或者,如果你想输入更短的东西,你可以这样做
xmlns:b="http://www.springframework.org/schema/beans"
代替
xmlns:beans="http://www.springframework.org/schema/beans"
这将允许你做的事情
<b:bean id="beanId" class="x.y.z.BeanClass" />
内容总结
以上是互联网集市为您收集整理的java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?全部内容,希望文章能够帮你解决java – Spring 3 applicationContext-security-JDBC.xml有bean:bean不是bean?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。