re:MappingException“未找到类”仅在生产中

问题描述 投票:0回答:1

这是转贴,因为我确实需要帮助。我需要将我的项目连接到两个数据库,所以我看了symfony文档,我做了他们的解释,直到我将项目转到生产模式,这才起作用,在这里我尝试了连接,因为我的User类出现了MappingException在映射路径中找不到,idk原因。

这里是日志:

request.INFO: Matched route "agent_connexion". {"route":"agent_connexion","route_parameters":{"_route":"agent_connexion","_controller":"App\\Controller\\SecurityController::login"},"request_uri":"http://conge.local/connexion","method":"POST"} []
security.DEBUG: Checking for guard authentication credentials. {"firewall_key":"main","authenticators":1} []
security.DEBUG: Checking support on guard authenticator. {"firewall_key":"main","authenticator":"App\\Security\\LoginFormAuthenticator"} []
security.DEBUG: Calling getCredentials() on guard authenticator. {"firewall_key":"main","authenticator":"App\\Security\\LoginFormAuthenticator"} []
security.DEBUG: Passing guard token information to the GuardAuthenticationProvider {"firewall_key":"main","authenticator":"App\\Security\\LoginFormAuthenticator"} []
request.CRITICAL: Uncaught PHP Exception Doctrine\Persistence\Mapping\MappingException: "The class 'App\Entity\Mo\Agent' was not found in the chain configured namespaces App\Entity\Main" at D:\Programmation\CRNA\conge\vendor\doctrine\persistence\lib\Doctrine\Persistence\Mapping\MappingException.php line 23 {"exception":"[object] (Doctrine\\Persistence\\Mapping\\MappingException(code: 0): The class 'App\\Entity\\Mo\\Agent' was not found in the chain configured namespaces App\\Entity\\Main at D:\\Programmation\\CRNA\\conge\\vendor\\doctrine\\persistence\\lib\\Doctrine\\Persistence\\Mapping\\MappingException.php:23)"} []

正如您看到的错误在这里,可能是firewall_key错误。

这里是我的doctrin.yaml

doctrine:
    dbal:
        default_connection: customer
        connections:
            default:
                # configure these for your database server
                url: '%env(resolve:DATABASE_URL)%'
                server_version: '5.7'
                charset: utf8mb4
                mapping_types:
                    enum: string
            customer:
                # configure these for your database server
                url: '%env(DATABASE_Mo_URL)%'
                server_version: '5.7'
                charset: utf8mb4
                mapping_types:
                    enum: string

    orm:
        default_entity_manager: customer
        entity_managers:
            default:
                connection: default
                mappings:
                    Main:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Main'
                        prefix: 'App\Entity\Main'
                        alias: Main
            customer:
                connection: customer
                mappings:
                    Mo:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Mo'
                        prefix: 'App\Entity\Mo'
                        alias: Mo

现在是我的文件结构:

project_name
    src
        Entity
            Main
                some_entities
            Mo
                Agent.php (my User entity)
                some_entities
php symfony doctrine-orm doctrine
1个回答
0
投票

我解决了这个问题。我只是忘了修改config / packages / prod / doctrine.yaml,所以只有dev doctrine.yaml是正确的。

© www.soinside.com 2019 - 2024. All rights reserved.