- @EnableTransactionManagement is added on MyBootApplication
@Bean public Object testBean(PlatformTransactionManager platformTransactionManager){ System.out.println(">>>>>>>>>>TransactionManager is " + platformTransactionManager.getClass().getName()); return new Object(); }
it print TransactionManager is org.springframework.orm.jpa.JpaTransactionManager@Service open class UserService : BaseService() { @Autowired lateinit var repository: UserRepository @Transactional fun updateValid(id: Long, valid: Boolean) { ErrorConstant.ParamErrorCode.IdIsNull.caseThrow { id == 0.toLong() } repository.updateValid(id,valid) } }
i use spring.boot to build my project.
when i remove the @Transactional,everything is fine .
but when i add it. the repository is null,it can't be inject.
i read that question Using @Transaction annotation with @Autowired - Spring ,and i add spring.aop.proxy-target-class=true
in my application.properties ,still same error .
i use kotlin to write it,but i guess this is not the reason.
even so ,i will try with java later .
My mistake , I have some properties in BaseService , should add open on it too .