繁体   English   中英

Symfony 无法自动装配服务 不存在此类服务

[英]Symfony cannot autowire service no such service exists

更新

我将命令从 CoreBundle 移动到 AssetBundle 并忘记更改命名空间路径。 只需将 /CoreBundle/Command 重命名为 /AssetBundle/Command ,一切都会再次运行。

我遇到了无法解决的 Symfony 4.4 自动接线问题。

此错误与将服务注入帮助程序有关。 帮助器用于 Exporter 服务。 导出器服务是通过依赖注入文件构建的,并且在其中添加了帮助程序。

这是我的 Bundle 服务文件中的默认值

services:
    _defaults:
        autowire: true 
        autoconfigure: true
        public: false

这是我使用的标签的助手

X\ExportBundle\Service\Exporter\ExportColumn\Helper\AttributeHelper:
    tags:
        - { name: column_helper, alias: attribute_helper }

这是助手的接口

class AttributeHelper implements ExportColumnHelperInterface

这是助手的构造函数

/**
 * @param EntityManagerInterface $entityManager
 * @param AssetManager $assetManager
 */
public function __construct(EntityManagerInterface $entityManager, AssetManager $assetManager) 
{
    $this->assetManager = $assetManager;
    $this->entityManager = $entityManager;
}

这是我得到的错误

Cannot autowire service "X\ExportBundle\Service\Exporter\ExportColumn\Helper\AttributeHelper": argument "$assetManager" of method "__construct()" references class "X\AssetBundle\Service\Asset\AssetManager" but no such service exists.

非常感谢您的帮助!

在 yaml 中的服务配置中添加autowire: true

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM