データベースを使用して春からログイン システムを管理しようとしています。このチュートリアルに従ってデータベースを作成しました: http://www.mkyong.com/spring/maven-spring-jdbc-example/
そして、私はこの内容でdatasource.xmlファイルを作成しました:
<beans xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/login"/>
<property name="username" value="root"/>
<property name="password" value="pass"/>
</bean>
</beans>
これは私のsecurity.xmlです:
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Configuracion de Muestra
-
-->
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<beans:bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
<http auto-config='true'>
<intercept-url pattern="/**" access="ROLE_USER" />
<form-login default-target-url='/example/index.jsp'
always-use-default-target='true' />
</http>
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select nombre,password
from usuarios where username=?"
authorities-by-username-query="
select u.nombre, ur.rol from usuarios u, usuarios_roles ur
where u.user_id = ur.user_id and u.username =? "
/>
</authentication-provider>
</authentication-manager>
</beans:beans>
しかし、デプロイ時に次のエラーが発生しています:
Bean プロパティ 'dataSource' の設定中に Bean 'dataSource' への参照を解決できません。ネストされた例外は org.springframework.beans.factory.NoSuchBeanDefinitionException: 'dataSource' という名前の Bean が定義されていません
何が悪いのかわかりません:(