【问题标题】:Using spring-roo 2, how to add an user with spring security使用spring-roo 2,如何添加一个有spring security的用户
【发布时间】:2017-01-29 16:11:56
【问题描述】:

由于配置和设置是在 java 中,没有更多的 xml 配置文件,很难找到这种新设计的教程、文档和操作方法。所以......基本上,如何添加用户和他的密码,在哪里可以找到spring-security的安全配置“文件”(如旧的applicationContext-security.xml)......

然后,我做了一个 maven clean,从我的实体生成的 QClasse 消失了,所以应用程序不能再编译了。如何重新生成 QClasses(在 target/generated-sources/java 中)?

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

无论如何,请问如何使用新的 spring-security 配置添加用户。

我正在使用 Spring-roo 2.0.0.M3。

【问题讨论】:

    标签: spring-roo


    【解决方案1】:

    首先,我建议您查看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 或更高版本。

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-19
      • 1970-01-01
      • 1970-01-01
      • 2016-04-06
      • 2011-01-14
      • 2016-10-16
      • 1970-01-01
      • 2021-06-18
      相关资源
      最近更新 更多