使用spring-roo 2,如何添加具有弹簧安全性的用户

时间:2017-01-29 16:11:56

标签: spring-roo

由于配置和设置在java中,不再有xml配置文件,很难找到这个新设计的教程,文档和方法。所以...基本上,如何添加用户和他的密码,在哪里找到安全配置"文件" spring-security(如旧的applicationContext-security.xml)...

然后,我已经制作了一个maven clean,并且我的实体生成的QClasse消失了,因此应用程序无法再编译。如何重新生成QClasses(在target / generated-sources / java中)?

我注意到spring-roo项目是在Eclipse下用J2SE-1.5库创建的,所以它无法编译。我不得不将库更改为JDK1.8。错误覆盖方法的一些错误仍然存​​在。

无论如何,请如何为用户添加新的弹簧安全配置。

我使用的是Spring-roo 2.0.0.M3。

1 个答案:

答案 0 :(得分:0)

首先,我建议您查看Spring Boot,因为它是Spring Roo生成项目的基础。这将解释您如何定制项目配置的所有内容。

通过这种方式,有Spring Boot documentation about Spring Security及其how-to guides。配置用户的示例类是:

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
            auth.inMemoryAuthentication()
                .withUser("barry").password("password").roles("USER"); // ... etc.
    }

    // ... other stuff for application security

}
  

然后,我已经制作了一个maven clean,并且我的实体生成的QClasse消失了,因此应用程序无法再编译。如何重新生成QClasses(在target / generated-sources / java中)?

这些类由编译阶段的 apt-maven-plugin 插件生成。因此,只需简单地执行mvn clean complile即可生成它。

  

我注意到spring-roo项目是在Eclipse下用J2SE-1.5库创建的,所以它无法编译。我不得不将库更改为JDK1.8。错误覆盖方法的一些错误仍然存​​在

Spring Roo Reference Documentation中解释说Spring Roo需要JDK6作为 minimun java版本。另外,请检查maven版本是否为3.3或更高版本。

祝你好运!

相关问题