Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin使用@Autowired注解编译不通过 #6

Closed
20RenGY opened this issue Sep 14, 2022 · 5 comments
Closed

kotlin使用@Autowired注解编译不通过 #6

20RenGY opened this issue Sep 14, 2022 · 5 comments
Labels
help wanted Extra attention is needed 常见问题 常见问题

Comments

@20RenGY
Copy link

20RenGY commented Sep 14, 2022

@Autowired
var uid: Int?=null

@kymjs
Copy link
Collaborator

kymjs commented Sep 14, 2022

Kotlin与Java互调时,默认会将类封装并生成getter/setter方法,并将原变量至为不可访问。

有两种写法可以解决:

@JvmField
@Autowired
var uid: Int?=null

或者

@Autowired
lateinit var uid: Int

@kymjs kymjs closed this as completed Sep 14, 2022
@kymjs kymjs added the help wanted Extra attention is needed label Sep 19, 2022
@Er3c
Copy link

Er3c commented Sep 23, 2022

我也遇到了 不兼容的类型: NonExistentClass无法转换为Annotation @error.NonExistentClass()

@kymjs
Copy link
Collaborator

kymjs commented Sep 23, 2022

我也遇到了 不兼容的类型: NonExistentClass无法转换为Annotation @error.NonExistentClass()

参考kapt官方文档:https://kotlinlang.org/docs/kapt.html#non-existent-type-correction

kapt {
    correctErrorTypes true 
} 

@kymjs kymjs reopened this Sep 23, 2022
@kymjs kymjs closed this as completed Sep 23, 2022
@Er3c
Copy link

Er3c commented Sep 23, 2022

刚发现可能是你们迁移工具有点瑕疵,@Autowired阿里的引用包未删除导致的

@kymjs
Copy link
Collaborator

kymjs commented Sep 23, 2022

刚发现可能是你们迁移工具有点瑕疵,@Autowired阿里的引用包未删除导致的

是的,这个问题已经修复了,预计在国庆后发布新版本的迁移工具。

@kymjs kymjs added the 常见问题 常见问题 label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed 常见问题 常见问题
Projects
None yet
Development

No branches or pull requests

3 participants