douji9518
2017-12-19 15:47
浏览 74
已采纳

尝试连接两个数据库时出现Symfony错误

I'm trying to connect two databases but when I make a php bin/console doctrine:schema:update --force It return

No Metadata Classes to process.

Here is the doctrine configuration in config.yml

doctrine:
    dbal:
        default_connection: main
        connections:
            main:
                driver:   pdo_pgsql
                host:     '%database_host%'
                port:     '%database_port%'
                dbname:   '%database_name%'
                user:     '%database_user%'
                password: '%database_password%'
                charset:  UTF8
            rupe:
                driver:   pdo_pgsql
                host:     '%database_host2%'
                port:     '%database_port2%'
                dbname:   '%database_name2%'
                user:     '%database_user2%'
                password: '%database_password2%'
                charset:  UTF8

    orm:
        default_entity_manager: main
        entity_managers:
            main:
                connection: main
                mappings:
                    Main:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/AppBundle/Entity/Main'
                        prefix: 'AppBundle\\Entity\\Main'
                        alias: Main
            login:
                connection: main
                mappings:
                    LoginBundle:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/LoginBundle/Entity'
                        prefix: 'LoginBundle\\Entity'
                        alias: LoginBundle
            rupe:
                connection: rupe
                mappings:
                    Rupe:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/AppBundle/Entity/Rupe'
                        prefix: 'AppBundle\\Entity\\Rupe'
                        alias: Rupe
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • dongsheng4679 2017-12-20 13:49
    最佳回答

    I got a solution on Symfony 3.4 version

    doctrine:
        dbal:
            default_connection: main
            connections:
                main:
                    driver:   pdo_pgsql
                    host:     '%database_host%'
                    port:     '%database_port%'
                    dbname:   '%database_name%'
                    user:     '%database_user%'
                    password: '%database_password%'
                    charset:  UTF8
                rupe:
                    driver:   pdo_pgsql
                    host:     '%database_host2%'
                    port:     '%database_port2%'
                    dbname:   '%database_name2%'
                    user:     '%database_user2%'
                    password: '%database_password2%'
                    charset:  UTF8
    
        orm:
            default_entity_manager: main
            entity_managers:
                main:
                    connection: main
                    mappings:
                        AppBundle:  ~
                        LoginBundle: ~
                rupe:
                    connection: rupe
                    mappings:
                        RupeBundle: ~
    

    Hope it helps someone else!

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题