我來這裡問我的問題是因?yàn)槲艺娴牟恢涝撛觞N辦,而且我在網(wǎng)路上找不到正確的資訊。 我正在尋找用於與 BigQuery API (GCP) 通訊的服務(wù)綁定參數(shù)。為此,我傳遞了「parameters.yml」中的參數(shù),並將參數(shù)綁定在「services.yml」中。當(dāng)我重新載入頁面時(shí),發(fā)生錯(cuò)誤:「檔案/home/docker/symfony/src/xxx/DependencyInjection/../Resources/config/services.yml」不包含有效的YAML:冒號(hào)不能在不帶引號(hào)的情況下使用第84 行的映射值(「$bucketName:%google_bucket_name%」附近)。
您知道問題的根源是什麼嗎?
請(qǐng)尋找附件中的「services.yml」和「parameters.yml」檔案的相關(guān)部分
-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的參數(shù)有問題
預(yù)先感謝您的幫助;)
正如@bossman 已經(jīng)指出的那樣,答案是意圖。
我只是想補(bǔ)充一點(diǎn),你可以去掉很多不需要重複的內(nèi)容。當(dāng)你這樣寫:
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%"