- Demo继承一个父类,然后父类中使用inject注入一个bean,这个时候会报错,
- with
@xxx
must be define class annotation - 提示的错误信息是,使用属性注解必须有类注解,,问题是父类中应该不需要有类注解的么?不懂求解
- 父类中怎么处理,不懂!!
DemoCommand
<?php declare(strict_types=1);
namespace AppConsoleCommand;
use SwoftConsoleAnnotationMappingCommand;
use SwoftConsoleAnnotationMappingCommandMapping;
/**
* @Command()
*/
class DemoCommand extends CommCommand
{
/**
* @CommandMapping()
*/
public function test(): void
{
$this->tests();
var_dump("test_demo");
}
}
CommCommand
<?php declare(strict_types=1);
namespace AppConsoleCommand;
use AppServiceDemoService;
use SwoftBeanAnnotationMappingInject;
class CommCommand
{
/**
* @Inject()
* @var DemoService
*/
private $d;
public function tests() {
$this->d->demo();
var_dump("tests");
}
}
DemoService
<?php declare(strict_types=1);
namespace AppService;
use SwoftBeanAnnotationMappingBean;
/**
* @package AppService
* @Bean(name="demoservice", scope=Bean::PROTOTYPE)
*/
class DemoService {
public function demo() {
var_dump("demo");
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…