首頁  >  問答  >  主體

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粉448130258178 天前333

全部回覆(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
  • 取消回覆