我有Aspect类需要在其方法中计算一些东西。它必须从yaml文件中获取值。我试图用单元测试来运行它。 application.yaml位于src / test / resources中。当我调试它时,我注意到当触发该方法时,字段未初始化,它们为NULL。从文件中读取值的所有其他类都很好。这可能是什么问题?
select allowdeductname_en,
sum(case when mh.costcenter_code = 99990001 then sfd_comp_value_tax end) as ggg
from tpydprocmtdd md
left join tpydprocmtdh mh on md.procmtdh_id = mh.procmtdh_id
and md.company_id = mh.company_id
and year(mh.paydate) = 2017
and month(mh.paydate) = 1
where md.allowdeducttype = 'A'
and md.company_id = 13565
group by allowdeductname_en
order by allowdeductname_en;
当我添加@PostConstruct init方法时。工作正常。
@Value("${enabled:true}")
private boolean enabled;
public Aspect() {
LOGGER.info(Aspect.class.getName() + " aspect initialized ");
}
@Before("within(services..*) && @annotation(resolver)")
public void resolver(JoinPoint joinPoint, R resolver){
When we are here the values from the fields are null .
}