我有一个在春季实施的现有项目,现在我正在将这个项目移动到春季启动。现有项目包含spring-security.xml
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security https://www.springframework.org/schema/security/spring-security.xsd">
<http auto-config="true" pattern="/dashboard*" use-expressions="true" >
<intercept-url pattern="/dashboard*" access="hasRole('ROLE_NORMAL_USER')" />
<form-login login-page="/logout" default-target-url="/dashboard"
authentication-failure-url="/loginerrorpage" />
<session-management>
<concurrency-control max-sessions="12" expired-url="/logout"/>
</session-management>
<custom-filter after="LOGIN_PAGE_FILTER" ref="LoginFilter" />
<logout invalidate-session="true" logout-success-url="/logout" logout-url="/j_spring_security_logout"/>
<csrf disabled="true" />
</http>
<http auto-config="true">
<intercept-url pattern="/entrance" access="hasRole('ROLE_NORMAL_USER')" />
<form-login login-page="/login" default-target-url="/entrance"
authentication-failure-url="/loginerrorpage" />
<session-management>
<concurrency-control max-sessions="12" expired-url="/logout"/>
</session-management>
<logout invalidate-session="true" logout-success-url="/logout" logout-url="/j_spring_security_logout"/>
<csrf disabled="true" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="user1" password="password1" authorities="ROLE_NORMAL_USER" />
<user name="user2" password="password2" authorities="ROLE_NORMAL_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<beans:bean id="LoginFilter" class="com.codemaster.LoginFilter"/>
</b:beans>
有没有人知道如何将上面的配置移动到spring boot配置
直接将流动类添加到您的项目中。
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource("classpath:spring-security.xml")
public class SecurityConfig {
}