私のカスタムUsernamePasswordAuthenticationFilterを登録したいのですが、それを行うと、属性 'id'が表示されないというエラーが表示されます私はタグのどこかで間違いを犯したと知っていますが、このタグがどのように機能しているか分かりません。ここでは、バネのsecurity.xmlです:lineNumber:12; columnNumber:139; cvc-complex-type.2.4.a:要素 'beans:bean'で始まる無効なコンテンツが見つかりました
<beans:bean 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
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.2.xsd">
<bean id="loginUrlAuthenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<property name="loginFormUrl" value="/login" />
</bean>
<bean id="successHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<property name="defaultTargetUrl" value="/login" />
</bean>
<bean id="failureHandler" class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<property name="defaultFailureUrl" value="/login?error=true" />
</bean>
<bean id="myAuthFilter"
class="com.webproject.MyAuthFilter">
<property name="authenticationManager" ref="authenticationManager" />
<property name="authenticationFailureHandler" ref="failureHandler" />
<property name="authenticationSuccessHandler" ref="successHandler" />
</bean>
<http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint">
<intercept-url pattern="/courses**" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/mycourses**" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/courses/**" access="hasRole('ROLE_USER')" />
<custom-filter position="FORM_LOGIN_FILTER" ref="myAuthFilter" />
<csrf disabled="true" />
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query=
"select username,passwort, enabled from users where username=?"
authorities-by-username-query=
"select username, user_role from user_roles where username =? " />
</authentication-provider>
</authentication-manager>
に変更してください。エラーメッセージがはっきりしているようです。無効な構成では、 '要素があります。多分あなたは ''を意味していたでしょうか?そうでない場合、なぜその要素にIDが必要であると思いますか? –
Seelenvirtuose