Spring Security Java Configuration 1.0.0.M1(Milestone 1)是 Spring Security 项目早期发布的里程碑版本,于2013年左右推出,标志着 Spring Security 正式支持纯 Java 配置方式(即无需 XML),与 Spring 3.2+ 的@Configuration和@EnableWebSecurity等注解深度集成。该版本引入了核心的 Java DSL 雏形,例如:
@EnableWebSecurity启用 Web 安全配置- 继承
WebSecurityConfigurerAdapter(已在 Spring Security 5.7+ 中弃用,6.0+ 中移除) - 通过
HttpSecurity进行链式配置(如.authorizeRequests(),.formLogin()) - 支持基于
AuthenticationManagerBuilder的认证配置
⚠️ 注意:1.0.0.M1 是非常早期的预发布版本,不适用于生产环境;现代开发应使用 Spring Security 6.x(基于 Jakarta EE 9+、无 XML、无 WebSecurityConfigurerAdapter,采用SecurityFilterChainBean 方式)。
示例(M1 风格,已过时):
@Configuration@EnableWebSecuritypublicclassSecurityConfigextendsWebSecurityConfigurerAdapter{@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().anyRequest().authenticated().and().formLogin();}}✅ 当前推荐方式(Spring Security 6.2+):
@BeanpublicSecurityFilterChainfilterChain(HttpSecurityhttp)throwsException{http.authorizeHttpRequests(auth->auth.anyRequest().authenticated()).formLogin(withDefaults());returnhttp.build();}Spring Security Java Configuration 1.0.0.M1 Released
I’m pleased to announce the release of Spring Security Java Configuration as a stand alone module. The milestone is compatible with Spring 3.2.3.RELEASE+ and Spring Security 3.1.4.RELEASE.
This code has been merged into Spring Security 3.2.0.M2 release and will be maintained within the Spring Security code base going forward. We hope that by making the release available for stable versions of Spring and Spring Security it will encourage you to try it sooner and provide us feedback before the final release.
Stay tuned to the SpringSource blog for an article that walks you through how to use Spring Security Java Configuration. In the mean time, you can find out how to obtain spring-security-javaconfig, documentation, and samples at http://github.com/SpringSource/spring-security-javaconfig.
comments powered by Disqus