Spring 在Kotlin中使用@Service时引发异常
我正在用Kotlin编写一个SSM项目,只要我尝试用Spring 在Kotlin中使用@Service时引发异常,spring,kotlin,ssm,Spring,Kotlin,Ssm,我正在用Kotlin编写一个SSM项目,只要我尝试用@service注释一个类(服务实现),就会发生这种情况 尝试用Java编写这个实现类,结果一切正常。 试图只保留必要的重写方法 open已添加 上下文:已配置组件扫描 其他信息: 相关结构 - src - kotlin - service An interface - impl -> The implementation <- @Service open c
@service
注释一个类(服务实现),就会发生这种情况
open
已添加上下文:已配置组件扫描
其他信息: 相关结构
- src
- kotlin
- service
An interface
- impl
-> The implementation <-
@Service
open class SeckillServiceImpl : SeckillService {
override fun getAll(): List<Seckill> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun getById(seckillId: Long): Seckill? {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun exportSeckillUrl(seckillId: Long): SeckillUrlExposer {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun doSeckill(seckillId: Long, userPhone: Long, md5: String?): SeckillExecutionResult {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
试图只保留必要的方法
- src
- kotlin
- service
An interface
- impl
-> The implementation <-
@Service
open class SeckillServiceImpl : SeckillService {
override fun getAll(): List<Seckill> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun getById(seckillId: Long): Seckill? {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun exportSeckillUrl(seckillId: Long): SeckillUrlExposer {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun doSeckill(seckillId: Long, userPhone: Long, md5: String?): SeckillExecutionResult {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
@服务
开放类seckillserviceinpl:SeckillService{
覆盖fun getAll():列表{
TODO(“未实现”)//要更改已创建函数的主体,请使用文件|设置|文件模板。
}
覆盖有趣的getById(seckillId:Long):Seckill{
TODO(“未实现”)//要更改已创建函数的主体,请使用文件|设置|文件模板。
}
覆盖有趣的导出seckillurl(seckillId:Long):SeckillUrlExposer{
TODO(“未实现”)//要更改已创建函数的主体,请使用文件|设置|文件模板。
}
重写fun-doSeckill(seckillId:Long,userPhone:Long,md5:String?):SeckillExecutionResult{
TODO(“未实现”)//要更改已创建函数的主体,请使用文件|设置|文件模板。
}
}
怎么了,我该怎么办?谢谢 Spring需要的Kotlin装在一个单独的罐子里。尝试将其添加到您的构建中:
build.gradle
:
compile 'org.jetbrains.kotlin:kotlin-reflect:1.1.51'
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.1.51</version>
</dependency>
pom.xml
:
compile 'org.jetbrains.kotlin:kotlin-reflect:1.1.51'
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.1.51</version>
</dependency>
org.jetbrains.kotlin
科特林反射
1.1.51
@madhead的计划非常有效,但需要注意的是,kotlin反映的依赖版本需要与项目中的kotlin版本保持一致。
建议使用以下措辞
pom.xml
:
org.jetbrains.kotlin
科特林反射
${kotlin.version}