草庐IT

autowired

全部标签

php - 无法 Autowiring 服务 : Argument references class but no such service exists

我正在将项目从Symfony3升级到Symfony4(https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md)我有很多像这样的存储库/服务:namespaceApp\Entity;useApp\Entity\Activation;useDoctrine\ORM\EntityRepository;usePredis\Client;classActivationRepositoryextendsEntityRepository{//...}当我尝试像这样在浏览器中运行项目时:http://localhost:8000/lo

@Resource和@Autowired的区别

1.相同点@Resource和@Autowired这两个注解的作用都是在Spring生态里面去实现Bean的依赖注入2.不同点2.1@Autowired首先,@Autowired是Spring里面提供的一个注解,默认是根据类型来实现Bean的依赖注入。@Autowired注解里面有一个required属性默认值是true,表示强制要求bean实例的注入,在应用启动的时候,如果IOC容器里面不存在对应类型的Bean,就会报错。当然,如果不希望自动注入,可以把这个属性设置成false。@ControllerpublicclassHelloController{@Autowired(required

java - BeanNotOfRequiredTypeException 由于 Autowiring 字段

我还是SpringMVC的新手,在构建我的测试项目时,我从Tomcat日志中收到了这条消息:SEVERE:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'divisionController':Injectionofresourcedepen

java - BeanNotOfRequiredTypeException 由于 Autowiring 字段

我还是SpringMVC的新手,在构建我的测试项目时,我从Tomcat日志中收到了这条消息:SEVERE:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'divisionController':Injectionofresourcedepen

使用@Component时再使用@Resource或@Autowired时注入失败问题

前言在@Component注解的类下,再使用了@Resource或@Autowired注解。如此操作会导致依赖注入失败。这是因为spring加载它们的顺序不同,在使用@Component注解将bean实例化到spring容器内的时候,因为@Autowired是在这个bean之中的,此时@Autowired还未完成自动装载,所以导致依赖注入的service为null@Component和@Autowired或@Resource在Spring应用程序中,@Component注解用于将类标记为可自动扫描的组件。当Spring容器启动时,会扫描带有@Component注解的类,并将它们实例化为bean

java - 将 @Transaction 注释与 @Autowired 一起使用 - Spring

好吧,我有一个带有@Service注释的类和一些奇怪的事件:当我将注释@Transaction放在某些方法中时,我无法启动tomcat服务器,我收到错误:“无法Autowiring...”在另一个当我使用我的@Autowired时上课,但是当我删除@Transaction时一切正常。我的类(class)标题是:@Service(value="caixaBO")publicclassCaixaBOImplextendsBasicBOImpl{我的方法签名是:@Transactional(propagation=Propagation.REQUIRED)publicvoidmoviment

java - 将 @Transaction 注释与 @Autowired 一起使用 - Spring

好吧,我有一个带有@Service注释的类和一些奇怪的事件:当我将注释@Transaction放在某些方法中时,我无法启动tomcat服务器,我收到错误:“无法Autowiring...”在另一个当我使用我的@Autowired时上课,但是当我删除@Transaction时一切正常。我的类(class)标题是:@Service(value="caixaBO")publicclassCaixaBOImplextendsBasicBOImpl{我的方法签名是:@Transactional(propagation=Propagation.REQUIRED)publicvoidmoviment

java - Spring 3 中的自定义 Autowire 候选 bean

假设我有以下结构,其中包含一个服务接口(interface)ServiceInterface和几个实现它的组件:ProductAService和ProductBService我还有一个RequestContextbean,它有一个限定属性,表明我们正在处理ProductA或ProductB。然后如何使用Autowiring或其他注释将正确的实现(ProductAService或ProductBService)自动注入(inject)到需要它的某些服务中(ServiceThatNeedsServiceInterface下面)。publicinterfaceServiceInterface

java - Spring 3 中的自定义 Autowire 候选 bean

假设我有以下结构,其中包含一个服务接口(interface)ServiceInterface和几个实现它的组件:ProductAService和ProductBService我还有一个RequestContextbean,它有一个限定属性,表明我们正在处理ProductA或ProductB。然后如何使用Autowiring或其他注释将正确的实现(ProductAService或ProductBService)自动注入(inject)到需要它的某些服务中(ServiceThatNeedsServiceInterface下面)。publicinterfaceServiceInterface

java - 我不能在 Spring Autowiring 存储库

我正在尝试使用spring注释在Controller中Autowiring存储库。我收到错误org.springframework.data.repository.query.QueryByExampleExecutorclassnotfound我找不到解决方案。我得到的错误:SEVERE:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory