搜索

首页  >  问答  >  正文

services.yml 中出现“冒号不能在未加引号的映射值中使用”错误

我来这里问我的问题是因为我真的不知道该怎么办,而且我在互联网上找不到正确的信息。 我正在寻找用于与 BigQuery API (GCP) 通信的服务绑定参数。为此,我传递了“parameters.yml”中的参数,并将参数绑定在“services.yml”中。当我重新加载页面时,出现错误:“文件 /home/docker/symfony/src/xxx/DependencyInjection/../Resources/config/services.yml”不包含有效的 YAML:冒号不能在不带引号的情况下使用第 84 行的映射值(“$bucketName:%google_bucket_name%”附近)。

您知道问题的根源是什么吗?

请查找附件中的“services.yml”和“parameters.yml”文件的相关部分

-services.yml

  AdminBundle\Services\CustomerChangeSetService:
    public: true
    autowire: true
    autoconfigure: true
    bind:
      $googleProjectId: "%google_project_id%"
      $googlePath: "%kernel.root_dir%/../%google_token_path%"
      $googleQuery: "%google_bigquery_dataset%"
      $googleConfig: "%config_bigQuery_prod%"
      $tableName: "%google_bigquery_table_customerchangeset%"
      $bucketName: "%google_bucket_name%"

  AdminBundle\Services\APILogsService:
    public: true
    autowire: true
    autoconfigure: true
    bind:
      $googleProjectId: "%google_project_id%"
      $googlePath: "%kernel.root_dir%/../%google_token_path%"
      $googleQuery: "%google_bigquery_dataset%"
      $googleConfig: "%config_bigQuery_prod%"
      $tableName: "%google_bigquery_table_apilogs%"
      $bucketName: "%google_bucket_name%"

  AdminBundle\Services\ImportLicenceCodeService:
    public: true
      autowire: true
      autoconfigure: true
      bind:
        $googleProjectId: "%google_project_id%"
        $googlePath: "%kernel.root_dir%/../%google_token_path%"
        $googleQuery: "%google_bigquery_dataset%"
        $googleConfig: "%config_bigQuery_prod%"
        $tableName: "%google_bigquery_table_importlicencecode%"
        $bucketName: "%google_bucket_name%"

-parameters.yml

    google_token_path: ./google_token.json
    google_project_id: "xxx"
    google_bigquery_dataset: "xxx"
    google_bigquery_table_accessmember: "xxx"
    google_bigquery_table_customerchangeset: "xxx"
    google_bigquery_table_apilogs: "xxx"
    google_bigquery_table_importlicencecode: "xxx"
    google_bucket_name: "xxx"

PS:代码好像是ImportLicenceCodeService的参数有问题

预先感谢您的帮助;)

P粉448130258P粉448130258243 天前381

全部回复(1)我来回复

  • P粉895187266

    P粉8951872662024-03-30 00:35:04

    正如@bossman 已经指出的那样,答案是意图。

    我只是想补充一点,你可以去掉很多不需要的重复内容。当你这样写时:

    services:
        _defaults:
            autowire: true
            autoconfigure: true
            bind:
                $googleProjectId: "%google_project_id%"
                $googlePath: "%kernel.root_dir%/../%google_token_path%"
                $googleQuery: "%google_bigquery_dataset%"
                $googleConfig: "%config_bigQuery_prod%"            
                $bucketName: "%google_bucket_name%"
    
      AdminBundle\Services\CustomerChangeSetService:
        public: true
        bind:
            $tableName: "%google_bigquery_table_customerchangeset%"
    
    
      AdminBundle\Services\APILogsService:
        public: true
        bind:
            $tableName: "%google_bigquery_table_apilogs%"
    
    
      AdminBundle\Services\ImportLicenceCodeService:
        public: true
        bind:
            $tableName: "%google_bigquery_table_importlicencecode%"

    回复
    0
  • 取消回复