草庐IT

xml - maven spring - 找不到元素 'beans'的声明

我有一个使用maven(打包为jar)构建的spring项目(依赖项被复制到单独的目录并添加到类路径中)我想以java-jar的形式运行它问题是当我运行它时,我得到:原因:org.xml.sax.SAXParseException:cvc-elt.1:找不到声明元素“bean”。这是因为spring.schemas和spring.handlers位于几个jar中,即:spring-beans等。有什么办法可以解决,假设我不想用shade插件解压所有依赖,把spring.schemas和spring.handlers的内容串联起来?我还想避免在我的项目中保存xsd文件并将schemaLo

xml - maven spring - 找不到元素 'beans'的声明

我有一个使用maven(打包为jar)构建的spring项目(依赖项被复制到单独的目录并添加到类路径中)我想以java-jar的形式运行它问题是当我运行它时,我得到:原因:org.xml.sax.SAXParseException:cvc-elt.1:找不到声明元素“bean”。这是因为spring.schemas和spring.handlers位于几个jar中,即:spring-beans等。有什么办法可以解决,假设我不想用shade插件解压所有依赖,把spring.schemas和spring.handlers的内容串联起来?我还想避免在我的项目中保存xsd文件并将schemaLo

java - Camel - 将特定参数从路由传递到通用 bean 方法

假设我有一条看起来像这样的Camel路线:from("direct:myRoute").setHeader("someHeader",simple("someheadervalue")).beanRef("myBean","beanMethod");我有一个无法更改的bean,它看起来像这样:publicclassMyBean{publicvoidbeanMethod(StringheaderExpected){//dosomethingwiththevaluehere.}}基本上,我想将someHeader的值从myRoute传递给MyBean中的beanMethod。p>知道bea

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

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 - 未能读取架构文档 '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