草庐IT

Bean-IOC

全部标签

java - Spring Boot 2.1 bean 覆盖与 Primary

与SpringBoot2.1beanoverridingisdisabled默认情况下,这是一件好事。但是我确实有一些测试,我使用Mockito将bean替换为模拟实例。使用默认设置,这种配置的测试将由于bean覆盖而失败。我发现唯一可行的方法是通过应用程序属性启用bean覆盖:spring.main.allow-bean-definition-overriding=true但是我真的很想确保为我的测试配置设置最少的bean定义,spring会在禁用覆盖的情况下指出这一点。我要覆盖的bean要么是在导入到我的测试配置中的另一个配置中定义通过注解扫描自动发现bean我的想法应该在覆盖be

java - Spring Boot 2.1 bean 覆盖与 Primary

与SpringBoot2.1beanoverridingisdisabled默认情况下,这是一件好事。但是我确实有一些测试,我使用Mockito将bean替换为模拟实例。使用默认设置,这种配置的测试将由于bean覆盖而失败。我发现唯一可行的方法是通过应用程序属性启用bean覆盖:spring.main.allow-bean-definition-overriding=true但是我真的很想确保为我的测试配置设置最少的bean定义,spring会在禁用覆盖的情况下指出这一点。我要覆盖的bean要么是在导入到我的测试配置中的另一个配置中定义通过注解扫描自动发现bean我的想法应该在覆盖be

java - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'MyController' :

我正在做spring+hibernate应用程序。当我在tomcat服务器上运行应用程序时,我遇到了一些异常。INFO:org.springframework.web.servlet.DispatcherServlet-FrameworkServlet'appServlet':initializationstartedINFO:org.springframework.web.context.support.XmlWebApplicationContext-RefreshingWebApplicationContextfornamespace'appServlet-servlet':st

java - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'MyController' :

我正在做spring+hibernate应用程序。当我在tomcat服务器上运行应用程序时,我遇到了一些异常。INFO:org.springframework.web.servlet.DispatcherServlet-FrameworkServlet'appServlet':initializationstartedINFO:org.springframework.web.context.support.XmlWebApplicationContext-RefreshingWebApplicationContextfornamespace'appServlet-servlet':st

java - Spring Boot Test 失败说,由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext

测试类:-@RunWith(SpringRunner.class)@SpringBootTest(classes={WebsocketSourceConfiguration.class,WebSocketSourceIntegrationTests.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT,properties={"websocket.path=/some_websocket_path","websocket.allowedOrigins=*","spring.cloud.stream.default

java - Spring Boot Test 失败说,由于缺少 ServletWebServerFactory bean,无法启动 ServletWebServerApplicationContext

测试类:-@RunWith(SpringRunner.class)@SpringBootTest(classes={WebsocketSourceConfiguration.class,WebSocketSourceIntegrationTests.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT,properties={"websocket.path=/some_websocket_path","websocket.allowedOrigins=*","spring.cloud.stream.default

Spring 预计至少有 1 个 bean 有资格作为此依赖项的 Autowiring 候选者

我在使用这个Autowire时遇到了问题:@ControllerpublicclassChiusuraController{@AutowiredprivateChiusuraProviderchiusuraProvider;}用这个bean:@Service@TransactionalpublicclassChiusuraProviderextendsThreadProvider{publicvoidrun(){}}延伸publicabstractclassThreadProviderextendsThreadimplementsInitializingBean,Runnable,Di

Spring 预计至少有 1 个 bean 有资格作为此依赖项的 Autowiring 候选者

我在使用这个Autowire时遇到了问题:@ControllerpublicclassChiusuraController{@AutowiredprivateChiusuraProviderchiusuraProvider;}用这个bean:@Service@TransactionalpublicclassChiusuraProviderextendsThreadProvider{publicvoidrun(){}}延伸publicabstractclassThreadProviderextendsThreadimplementsInitializingBean,Runnable,Di

java - SpringBoot - BeanDefinitionOverrideException : Invalid bean definition

我正在尝试使用SpringBoot在本地设置DynamoDB。最初,我使设置正常工作,并且能够通过存储库写入/保存到DynamoDB。从那时起,我添加了更多类来构建我的应用程序。现在,当我尝试启动我的应用程序时,出现以下异常:org.springframework.beans.factory.support.BeanDefinitionOverrideException:Invalidbeandefinitionwithname'agentRepository'definedinnull:Cannotregisterbeandefinition[Rootbean:class[org.s

java - SpringBoot - BeanDefinitionOverrideException : Invalid bean definition

我正在尝试使用SpringBoot在本地设置DynamoDB。最初,我使设置正常工作,并且能够通过存储库写入/保存到DynamoDB。从那时起,我添加了更多类来构建我的应用程序。现在,当我尝试启动我的应用程序时,出现以下异常:org.springframework.beans.factory.support.BeanDefinitionOverrideException:Invalidbeandefinitionwithname'agentRepository'definedinnull:Cannotregisterbeandefinition[Rootbean:class[org.s