簡體   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