草庐IT

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

java - 如何以编程方式创建具有注入(inject)属性的 bean 定义?

我想以编程方式将bean定义添加到应用程序上下文,但该定义的某些属性是该上下文中的其他bean(我知道它们的名称)。我该怎么做才能注入(inject)这些属性?例如:GenericBeanDefinitionbeanDef=newGenericBeanDefinition();beanDef.setBeanClass(beanClass);MutablePropertyValuesvalues=newMutablePropertyValues();values.addPropertyValue("intProperty",10);values.addPropertyValue("str

java - 如何以编程方式创建具有注入(inject)属性的 bean 定义?

我想以编程方式将bean定义添加到应用程序上下文,但该定义的某些属性是该上下文中的其他bean(我知道它们的名称)。我该怎么做才能注入(inject)这些属性?例如:GenericBeanDefinitionbeanDef=newGenericBeanDefinition();beanDef.setBeanClass(beanClass);MutablePropertyValuesvalues=newMutablePropertyValues();values.addPropertyValue("intProperty",10);values.addPropertyValue("str

java - 使用构造函数参数字段填充 Spring bean

如何使用该字段注入(inject)包含要用作附加构造函数arg的Map的属性文件。从属性文件加载mapbean当前设置使用:Java等价物:Mapconfiguration=EmbeddedGraphDatabase.loadConfigurations("neo4j_config.props");GraphDatabaseServicegraphDb=newEmbeddedGraphDatabase("data/neo4j-db",configuration);谢谢 最佳答案 类似这样的:这利用了theabilitytocreat

java - 使用构造函数参数字段填充 Spring bean

如何使用该字段注入(inject)包含要用作附加构造函数arg的Map的属性文件。从属性文件加载mapbean当前设置使用:Java等价物:Mapconfiguration=EmbeddedGraphDatabase.loadConfigurations("neo4j_config.props");GraphDatabaseServicegraphDb=newEmbeddedGraphDatabase("data/neo4j-db",configuration);谢谢 最佳答案 类似这样的:这利用了theabilitytocreat

java - Spring bean 销毁方法、单例和原型(prototype)范围

我是spring框架的新手,从一些教程开始学习它。我有以下文件,#MainProgram.javapackagetest.spring;importorg.springframework.context.support.AbstractApplicationContext;importorg.springframework.context.support.ClassPathXmlApplicationContext;publicclassMainProgram{publicstaticvoidmain(String[]args){AbstractApplicationContextco