设置多个db symfony 2.5时出错

时间:2014-08-18 17:38:47

标签: database symfony doctrine-orm

我正在尝试将2个数据库设置为我的symfony 2.5项目,但是出现了这个错误:

 Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\InvalidArgumentException' with message 'The service definition "doctrine.dbal.default_connection" does not exist.' \services\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass.php on line 48

Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: The service definition "doctrine.dbal.default_connection" does not exist. in services\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ContainerBuilder.php on line 867

Symfony\Component\DependencyInjection\Exception\InvalidArgumentException: Unable to replace alias "doctrine.dbal.default_connection" with "database_connection"

这是我的学说定义config.yml

doctrine:    
    dbal:
        default_connection:   default
        connections:
            default:
                driver:   pdo_mysql
                host:     localhost
                port:     ~
                name:     db1
                user:     root
                password: ~
            log:
                driver:   pdo_mysql
                host:     localhost
                port:     ~
                name:     db2
                user:     root
                password: ~

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

错误消息Unable to replace alias在处理多个数据库时提示您的配置中存在拼写错误。

使用此引用仔细检查您的配置:http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html