https://kotlinlang.org logo
#getting-started
Title
# getting-started
e

Erik Aaron Hansen

10/26/2021, 10:53 AM
hey! after having created a new spring initializr project through intellij I get this error in the project:
Classes annotated with '@Configuration' could be implicitly subclassed and must not be final
I've looked at the docs here: https://kotlinlang.org/docs/all-open-plugin.html, but the dependency
id("org.jetbrains.kotlin.plugin.allopen") version "1.3.72"
is already inside build.gradle.kts. are there other steps necessary after creating a new project? I'm using 11.0.11.hs-adpt as sdk.
j

Joffrey

10/26/2021, 10:56 AM
"All open" is generic, and needs to be configured so you tell it which annotation should force the class to be marked
open
. However, since Spring is so common, there is another plugin that is a superset of all-open, but with preconfigured annotations for Spring specifically:
Copy code
plugins {
  id "org.jetbrains.kotlin.plugin.spring" version "1.5.31"
}
It's described a bit lower on the same doc page: https://kotlinlang.org/docs/all-open-plugin.html#spring-support
@Configuration
-annotated components should be marked
open
out of the box with this Spring plugin
e

Erik Aaron Hansen

10/26/2021, 11:03 AM
thanks for explaining. if I replace the allopen dependency with the one you mention, I get an error: "Plugin with id 'org.jetbrains.kotlin.plugin.spring' was already requested at line 3". this is my plugins now:
Untitled.txt
h

hfhbd

10/26/2021, 11:09 AM
Just use this:
Copy code
plugins {
    id("org.springframework.boot") version "2.5.6"
    id("io.spring.dependency-management") version "1.0.11.RELEASE"
    kotlin("jvm") version "1.5.31"
    kotlin("plugin.spring") version "1.5.31"
}
j

Joffrey

10/26/2021, 11:11 AM
@Erik Aaron Hansen Actually the line
kotlin("plugin.spring")
is completely equivalent to
id("org.jetbrains.kotlin.plugin.spring")
, so you're declaring it twice. (Side note, I just mentioned the latest Kotlin version in my snippet, but you should use the same one for all Kotlin plugins - but 1.3.72 is pretty old, and Spring
1.0.11.RELEASE
actually uses
1.5.31
I believe)
e

Erik Aaron Hansen

10/26/2021, 11:15 AM
I see. okay, so I tried Philip's minimal list of plugins, but I still get the red squiggly line with the same error I mentioned above
j

Joffrey

10/26/2021, 11:16 AM
Do you get this error when running gradle via CLI?
e

Erik Aaron Hansen

10/26/2021, 11:16 AM
is there something wrong with the configuration of my code inspection tool?
no 🙂
j

Joffrey

10/26/2021, 11:16 AM
Then maybe your IDE is not properly synchronized with Gradle I guess, which one are you using?
e

Erik Aaron Hansen

10/26/2021, 11:19 AM
which gradle? I don't have it pre-installed
according to gradle-wrapper.properties, 7.2
j

Joffrey

10/26/2021, 11:26 AM
What I mean is that your IDE uses Gradle (through the wrapper in your case) to get information about dependencies and compiler plugins etc. In intelliJ IDEA for instance you can use the "reload all projects" button from the Gradle panel.
e

Erik Aaron Hansen

10/26/2021, 11:28 AM
oh, yeah I use the latest version of IntelliJ IDEA (2021.2.3)
j

Joffrey

10/26/2021, 11:29 AM
If that doesn't work you can also use the "invalidate caches" action
e

Erik Aaron Hansen

10/26/2021, 11:38 AM
I should mention I'm doing this on wsl but I'm sure this haven't been a problem earlier
I tried what you suggested, I even deleted the ~/.gradle folder, but I still get the same
j

Joffrey

10/26/2021, 11:46 AM
There is also a
.gradle
directory in your project folder that you can try to remove. But I still find this strange. I'm sorry I'm running out of ideas here
e

Erik Aaron Hansen

10/26/2021, 12:03 PM
thanks for trying 🙂
a

Alexey Belkov [JB]

10/29/2021, 8:09 AM
There is a regression in IDEA 2021.3 EAP, maybe that's the problem: https://youtrack.jetbrains.com/issue/KTIJ-19864
🙏 2
e

Erik Aaron Hansen

10/29/2021, 8:10 AM
I knew it had to be! thanks for posting 🙂
j

Joffrey

10/29/2021, 8:12 AM
@Erik Aaron Hansen our search was doomed from the start 😄
e

Erik Aaron Hansen

10/29/2021, 8:12 AM
yes Joffrey 😭
8 Views