从web.xml到Spring Boot
我正在升级一个现有的应用程序,以使用Spring Boot,并从web.xml迁移出去。 虽然我已经实现了功能,但我的web.xml中有一部分在我的一生中都不知道如何升级到spring boot。(如果有必要,我使用的是1.5.6) my web.xml的相关部分:从web.xml到Spring Boot,spring,spring-boot,weblogic,web.xml,weblogic12c,Spring,Spring Boot,Weblogic,Web.xml,Weblogic12c,我正在升级一个现有的应用程序,以使用Spring Boot,并从web.xml迁移出去。 虽然我已经实现了功能,但我的web.xml中有一部分在我的一生中都不知道如何升级到spring boot。(如果有必要,我使用的是1.5.6) my web.xml的相关部分: <security-constraint> <web-resource-collection> <web-resource-name>basic</web-resou
<security-constraint>
<web-resource-collection>
<web-resource-name>basic</web-resource-name>
<url-pattern>*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>User</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>myrealm</realm-name>
</login-config>
我还无法确定如何使用基于代码的方法设置镜像安全约束或登录配置的功能
如果有人对如何或能够为我指出正确的方向有任何想法,我将不胜感激。几个小时的谷歌搜索和尝试解决方案让我一无所获。查看
@EnableWebSecurity
和WebSecurityConfigurerAdapter
见下例:
@EnableWebSecurity
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/**").authenticated()
.anyRequest()
.permitAll()
.and().httpBasic()
.and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
}
也许要找一本教程“spring boot安全教程”?有了这个搜索词,你可以找到很多。
@EnableWebSecurity
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/**").authenticated()
.anyRequest()
.permitAll()
.and().httpBasic()
.and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
}