简体   繁体   中英

Using Kotlin classes from jar built with kotlin-maven-plugin

I've built a Java/Kotlin hybrid lib using kotlin-maven-plugin (v 1.2.21). The lib is actually a Spring Boot app (v 1.5.9)

Now, when I declare it as a dependency in another project I face strange issues : - My IDE (Intellij) is able to find the classes I need : auto-completion proposes me the classes, and I have no error - But when I try to build my application, I get compilation errors, saying the packages (and therefore the class) I am trying to import don't exist.

When I expand the jar in the IDE, I can see that the classes exist in the expected package, under a BOOT-INF/classes directory.

So I am a bit confused... is there a specific config to put in kotlin-maven-plugin , so that the generated jar can be used by others ?

Thanks

OK, so actually, it had nothing to do with Kotlin, but everything with Spring Boot...

Because of the change of structure in Spring Boot after 1.4.0 version as explained here , it's now required to add this config if you want to be able to import the jar

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <classifier>exec</classifier>
    </configuration>
</plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM