草庐IT

bean-validator

全部标签

java - 如何在需要引用过滤器bean的grails中注册spring bean

我正在尝试使用springsecurityoauth(库不是grails插件,只有一个非常过时的grails插件)。我希望我的应用成为OAuth1.0a提供者(而不是OAuth2)。spring-security-oauth的OAuth2部分似乎没有这个问题,因为它不需要在providerconfig中引用filterchain。我想要的是如下所示配置它:https://github.com/spring-projects/spring-security-oauth/blob/master/samples/oauth/sparklr/src/main/webapp/WEB-INF/ap

spring - 如何在我的 Controller 中验证(@Valid)之前检查安全访问(@Secured 或 @PreAuthorize)?

这是我的Controller代码:@PreAuthorize("hasRole('CREATE_USER')")@RequestMapping(method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)@ResponseBodypublicUserReturnROcreateUser(@Valid@RequestBodyUserROuserRO)throwsBadParameterException{returnuserSer

spring - 如何在我的 Controller 中验证(@Valid)之前检查安全访问(@Secured 或 @PreAuthorize)?

这是我的Controller代码:@PreAuthorize("hasRole('CREATE_USER')")@RequestMapping(method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)@ResponseBodypublicUserReturnROcreateUser(@Valid@RequestBodyUserROuserRO)throwsBadParameterException{returnuserSer

spring - 未能读取架构文档 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd'

在启动我的Spring应用程序时,我收到以下错误:WARNING:IgnoredXMLvalidationwarningorg.xml.sax.SAXParseException:schema_reference.4:Failedtoreadschemadocument'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd',because1)couldnotfindthedocument;2)thedocumentcouldnotberead;3)therootelementofthedocumentisno

spring - 未能读取架构文档 'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd'

在启动我的Spring应用程序时,我收到以下错误:WARNING:IgnoredXMLvalidationwarningorg.xml.sax.SAXParseException:schema_reference.4:Failedtoreadschemadocument'http://www.springframework.org/schema/beans/spring-beans-3.0.xsd',because1)couldnotfindthedocument;2)thedocumentcouldnotberead;3)therootelementofthedocumentisno

spring - 有没有办法覆盖组件扫描发现的 bean?

我有一个java配置类直接提供fooBean,通过组件扫描提供barBean。@Configuration@ComponentScan(basePackages={"com.blah"})publicclassConfig{@BeanpublicFooBeanfooBean{returnnewFooBean();}}我想在测试用例中重用它,我需要用模拟替换bean:@Configuration@Import(Config.class)publicclassTestConfig{@BeanpublicFooBeanfooBean{returnnewFooBeanMock();}@Bean

spring - 有没有办法覆盖组件扫描发现的 bean?

我有一个java配置类直接提供fooBean,通过组件扫描提供barBean。@Configuration@ComponentScan(basePackages={"com.blah"})publicclassConfig{@BeanpublicFooBeanfooBean{returnnewFooBean();}}我想在测试用例中重用它,我需要用模拟替换bean:@Configuration@Import(Config.class)publicclassTestConfig{@BeanpublicFooBeanfooBean{returnnewFooBeanMock();}@Bean

java - Spring - 在运行时注册作用域bean

我正在开发一个基于Spring的应用程序,它注册了一个自定义范围“任务”。这个想法是,当启动一个新任务时,Spring应该提供task-scoped对象。任务在运行时被实例化。它以Properties对象的形式提供了一些配置。我想将该对象注册到ApplicationContext但在任务范围内,以便该范围内的所有bean都可以引用该特定任务的配置。这是代码中的粗略想法:publicclassMyTaskextendsSourceTask{@Overridepublicvoidstart(Mapprops){context=ContextProvider.getApplicationCo

java - Spring - 在运行时注册作用域bean

我正在开发一个基于Spring的应用程序,它注册了一个自定义范围“任务”。这个想法是,当启动一个新任务时,Spring应该提供task-scoped对象。任务在运行时被实例化。它以Properties对象的形式提供了一些配置。我想将该对象注册到ApplicationContext但在任务范围内,以便该范围内的所有bean都可以引用该特定任务的配置。这是代码中的粗略想法:publicclassMyTaskextendsSourceTask{@Overridepublicvoidstart(Mapprops){context=ContextProvider.getApplicationCo

java - 如何在运行时实例化 Spring 托管 bean?

我坚持从纯Java到Spring的简单重构。应用程序有一个“容器”对象,它在运行时实例化它的部分。让我用代码解释一下:publicclassContainer{privateListruntimeBeans=newArrayList();publicvoidload(){//repeatedseveraltimesdependingonexternaldata/environmentRuntimeBeanbeanRuntime=createRuntimeBean();runtimeBeans.add(beanRuntime);}publicRuntimeBeancreateRuntim