草庐IT

autowired

全部标签

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 - 通过可迭代注入(inject)的标记服务中的类名获取服务

我正在努力通过类名从一组注入(inject)的标记服务中获取特定服务。举个例子:我将所有实现DriverInterface的服务标记为app.driver并将其绑定(bind)到$drivers变量。在其他一些服务中,我需要获取所有标记为app.driver的驱动程序,然后实例化并仅使用其中的少数驱动程序。但需要的驱动程序是动态的。服务.yml_defaults:autowire:trueautoconfigure:truepublic:falsebind:$drivers:[!taggedapp.driver]_instanceof:DriverInterface:tags:['ap

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 - Symfony - 依赖项未注入(inject)我的实体监听器类

我的Autowiring不适用于基本的文件实体监听器。我有一个File实体类,它使用注释来指定监听器,例如:/**@Orm\Entity(repositoryClass="root\CoreBundle\Repository\FileRepository")@Orm\EntityListeners({"root\CoreBundle\EventListener\Entity\FileEntityListener"})@Orm\Table(etc...FileEntityListener类开始如下:classFileEntityListener{private$encoderFactor

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(或者可能使用跨模块的上下文)?如果有更好的方法,我也愿意接受有关结构的建议。谢谢 最佳答案