swoft icon indicating copy to clipboard operation
swoft copied to clipboard

连接池注解不生效

Open shaniu00 opened this issue 5 years ago • 2 comments

我创建了一个普通类,但是match_redis是null,在控制器或者命令行脚本里面加就没有问题,帮忙排查下

use Swoft\Bean\Annotation\Mapping\Bean;
use Swoft\Bean\Annotation\Mapping\Inject;
use Swoft\Redis\Pool;

/**
 * Class BasicService
 *
 * @Bean()
 */
class BasicService
{
    /**
     * @Inject("redis.match_queue.pool")
     *
     * @var Pool
     */
    private $match_redis;

shaniu00 avatar Jun 05 '20 04:06 shaniu00

我是在脚本里面直接 new BasicService() 调用BasicService的方法

shaniu00 avatar Jun 09 '20 02:06 shaniu00

我是在脚本里面直接 new BasicService() 调用BasicService的方法

直接 new 是不会生效的。必须从容器拿,swoft才会介入处理注入

inhere avatar Jun 09 '20 08:06 inhere