草庐IT

bean-validator

全部标签

java - 服务层中的Spring @Validated

嘿嘿,我想在执行如下方法之前使用@Validated(group=Foo.class)注释来验证参数:publicvoiddoFoo(Foo@Validated(groups=Foo.class)foo){}当我将此方法放在我的Spring应用程序的Controller中时,@Validated被执行并在Foo对象无效时引发错误。但是,如果我在应用程序的Service层中的方法中放入相同的内容,则不会执行验证,并且即使Foo对象无效,该方法也会运行。不能在服务层使用@Validated注解吗?还是我必须做一些额外的配置才能让它工作?更新:我已将以下两个bean添加到我的service.

java - 服务层中的Spring @Validated

嘿嘿,我想在执行如下方法之前使用@Validated(group=Foo.class)注释来验证参数:publicvoiddoFoo(Foo@Validated(groups=Foo.class)foo){}当我将此方法放在我的Spring应用程序的Controller中时,@Validated被执行并在Foo对象无效时引发错误。但是,如果我在应用程序的Service层中的方法中放入相同的内容,则不会执行验证,并且即使Foo对象无效,该方法也会运行。不能在服务层使用@Validated注解吗?还是我必须做一些额外的配置才能让它工作?更新:我已将以下两个bean添加到我的service.

ruby-on-rails - ruby on rails、factory_girl、validates_presence_of 和多态关联

情况是这样的。Gems:rails3.2,factory_girl2.5.1classHousehas_one:address,:as=>:addressablevalidates:address,:presence=>trueaccepts_nested_attributes_for:addressendclassAddressattr_accessor:nestedbelongs_to:addressable,:polymorhic=>truevalidates:addressable,:presence=>true,:unless=>:nestedend这是如何运作的。定义工厂的

spring - 在实际 Web 请求之外使用请求范围的 bean

我有一个Web应用程序,它在一个单独的线程中运行了一个SpringIntegration逻辑。问题是在某些时候我的SpringIntegration逻辑尝试使用请求范围的bean,然后我得到以下错误:Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'scopedTarget.tenantContext':Scope'request'isnotactiveforthecurrentthread;considerdefiningascopedproxyfort

spring - 在实际 Web 请求之外使用请求范围的 bean

我有一个Web应用程序,它在一个单独的线程中运行了一个SpringIntegration逻辑。问题是在某些时候我的SpringIntegration逻辑尝试使用请求范围的bean,然后我得到以下错误:Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'scopedTarget.tenantContext':Scope'request'isnotactiveforthecurrentthread;considerdefiningascopedproxyfort

java - 创建名称为 'springSecurityFilterChain' 的 bean 时出错

我一直在关注SpringSecurityReference我只添加了这个类:@Configuration@EnableWebMvcSecuritypublicclassWebSecurityConfigextendsWebSecurityConfigurerAdapter{@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/login").pe

java - 创建名称为 'springSecurityFilterChain' 的 bean 时出错

我一直在关注SpringSecurityReference我只添加了这个类:@Configuration@EnableWebMvcSecuritypublicclassWebSecurityConfigextendsWebSecurityConfigurerAdapter{@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException{http.authorizeRequests().anyRequest().authenticated().and().formLogin().loginPage("/login").pe

spring - 无法自动接线。有多个 'DataSource' 类型的 bean

我正在尝试通过Autowiring数据库@AutowiredprivateDataSourcedataSource;我的application.yml中有一个数据源spring:profiles:active:dev---spring:profiles:devdatasource:driverClassName:org.mariadb.jdbc.Driverurl:jdbc:mariadb://localhost:3306/dbnameusername:userpassword:passwordname:devlogging:level:org.springframework:INFO

spring - 无法自动接线。有多个 'DataSource' 类型的 bean

我正在尝试通过Autowiring数据库@AutowiredprivateDataSourcedataSource;我的application.yml中有一个数据源spring:profiles:active:dev---spring:profiles:devdatasource:driverClassName:org.mariadb.jdbc.Driverurl:jdbc:mariadb://localhost:3306/dbnameusername:userpassword:passwordname:devlogging:level:org.springframework:INFO

ruby-on-rails - "temps.each(&:valid?)"在 Ruby 中是什么意思?

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Whatdoesmap(&:name)meaninRuby?each中的&:valid?是什么意思?我见过.each做|r|或其他什么,但不确定这个是如何工作的?