LoginSignup
0
0

More than 1 year has passed since last update.

Java→Kotlin化メモ

Last updated at Posted at 2022-08-13

起動時エラー

kotlin_module is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.4/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

対応

build.gradle.kts
jar {
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

gradle build error

xecution failed for task ':compileJava'.
java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0xa5488cf) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0xa5488cf

build.gradle.kts

build.gradle.kts
application {
    tasks.jar {
        duplicatesStrategy = DuplicatesStrategy.INCLUDE
    }
}

@Slf4jが効かない

未サポート

対応

logger.kt
import org.slf4j.Logger
import org.slf4j.LoggerFactory

val Any.log: Logger
    get() = LoggerFactory.getLogger(this.javaClass)

@RequireArgsControllerで用意したコンストラクタインジェクションが効かない

code

@RequireArgsController
class XYZ {
    private val context: ApplicationContext? = null
}

対応

アノテーションを削除。
手組みのコンストラクタへ引っ越し。

constructor(private val context: ApplicationContext)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0