草庐IT

autowire

全部标签

java - 在 ApplicationContext 中找到 Bean,但在尝试 Autowiring 时找不到

我有一个SpringJobLauncher实现,我正在尝试Autowiring到@Component类中,假设它称为SimpleComponent。这个名为SomeJobLauncher的作业启动器正在通过bean定义加载到Spring上下文中。如果我在Spring应用程序上下文中Autowiring到SimpleComponent中,并尝试通过getBean("someLauncher")获取bean,我将获取我的bean,然后没有问题。然而,尽管确认bean已100%加载到ApplicationContext中,但当我尝试将someLauncherAutowiring到Simple

java - 使用 Qualifier 注入(inject) Autowiring 的依赖项失败

我已经尝试了所有可以在任何地方找到的选项,我查看了之前针对该主题提出的所有问题并尝试了其中给出的解决方案,但没有任何效果,我得到的只是这个错误。错误INFO:LoadingXMLbeandefinitionsfromclasspathresource[spring.xml]Exceptioninthread"main"org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'circle':Injectionofautowireddependenciesfailed;nestede

php - 无法 Autowiring 服务

我正在尝试从FOSUserBundle(Symfony3.4)实现UserManager。服务/Register.phpuserManager=$userManager;}publicfunctionregister(){$user=$this->userManager->findUserByUsernameOrEmail('aaa@gmail.clom');if($user){returnfalse;}returntrue;}}当我尝试调用此方法时,我得到:Cannotautowireservice"AppBundle\Service\Register":argument"$user

php - Symfony2 - 使用 Controller Autowiring 服务

我能够使用Symfony2的新Autowiring功能将服务注入(inject)到服务中。但是,我无法将服务注入(inject)Controller。我没有做什么/做错了什么?这是我的services.yml文件:services:home_controller:class:AppBundle\Controller\HomeControllerautowire:true这是我的ServiceConsumerDemo:namespaceAppBundle\Services;classServiceConsumerDemo{private$serviceDemo;publicfunctio

php - 交响乐 4 : Event listener Cannot autowire UserInterface

当我将UserInterface添加到我的事件监听器时,出现以下错误:Cannotautowireservice"App\EventListener\ControllerListener":argument"$user"ofmethod"__construct()"referencesinterface"Symfony\Component\Security\Core\User\UserInterface"butnosuchserviceexists.Itcannotbeauto-registeredbecauseitisfromadifferentrootnamespace.我不知道发

php - 交响乐 4 : "Autowire: you should configure its value explicitly."

我开始使用Symfony4,当我尝试运行我的服务器时遇到以下错误:无法Autowiring服务“App\Controller\CharacterInformation”:方法“__construct()"是类型提示的“字符串”,您应该明确配置它的值。我如何实例化我的类:/***@Route("/")*@returnResponse*/functionmainPage(){$characterInformation=newCharacterInformation('eu');returnnewResponse($characterInformation->getCharacter());

php - 在 Symfony 3.3 中使用 DI 在抽象类中 Autowiring ,这可能吗?

我正在将Symfony3.2项目移动到Symfony3.3,我想使用DInewfeatures.我有readthedocs但到目前为止,我可以让它发挥作用。请参阅以下类定义:useHttp\Adapter\Guzzle6\Client;useHttp\Message\MessageFactory;abstractclassAParent{protected$message;protected$client;protected$api_count_url;publicfunction__construct(MessageFactory$message,Client$client,stri

java - 从不同的模块 Autowiring bean

我有一个大型应用程序,我想将其分解为可管理的模块。我在Jpa中使用spring(Hibernate作为提供者)。我想出了一个结构,其中我有一个包含所有实体和dao类的核心模块,其他模块使用关于持久性的核心模块,每个模块都有自己的一组服务类和Controller。所有Jpa和spring的配置文件都在核心模块中。通过此设置,我面临着在使用核心模块的模块中Autowiringdaobean的问题。所以我的问题是,是否可以从其他模块的核心模块Autowiringbean(或者可能使用跨模块的上下文)?如果有更好的方法,我也愿意接受有关结构的建议。谢谢 最佳答案

java - Autowiring 构造函数时 Camel 没有路线

我在模块中使用springboot。我有一个包含多个子模块的父项目。当我使用ContructorAutowiring配置路由时,Camel路由无法启动。我得到Total0routes,其中0已启动当像这样启动构造函数时。privatefinalScanProcessorscanProcessor;privatefinalScheduleProcessorscheduleProcessor;privatefinalTagProcessortagProcessor;privatefinalLatestScanProcessorlatestScanProcessor;privatefinal

java - @Autowired 和 default-autowire 可以共存吗?

意味着如果具有所需类型的bean不超过1个,bean的所有字段将自动注入(inject)依赖项。问题是当使用注解时它是如何工作的,它到底能不能工作。我的测试表明即使我使用@Resource(name="someConcreteFoo")privateFoofoo;如果Foo有多个实现,上下文会尝试按类型Autowiring字段,但会失败.所以,就我所见,default-autowire不与注释混合。我在文档中找不到任何具体内容。扩展问题-当使用xml-only时,spring如何使用默认Autowiring。IE。如果你有.属性注入(inject)是否覆盖默认值(应该是)。我可以做更多