hey! after having created a new spring initializr ...
# getting-started
e
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
"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
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
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
@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
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
Do you get this error when running gradle via CLI?
e
is there something wrong with the configuration of my code inspection tool?
no 🙂
j
Then maybe your IDE is not properly synchronized with Gradle I guess, which one are you using?
e
which gradle? I don't have it pre-installed
according to gradle-wrapper.properties, 7.2
j
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
oh, yeah I use the latest version of IntelliJ IDEA (2021.2.3)
j
If that doesn't work you can also use the "invalidate caches" action
e
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
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
thanks for trying 🙂
a
There is a regression in IDEA 2021.3 EAP, maybe that's the problem: https://youtrack.jetbrains.com/issue/KTIJ-19864
🙏 2
e
I knew it had to be! thanks for posting 🙂
j
@Erik Aaron Hansen our search was doomed from the start 😄
e
yes Joffrey 😭