从使用kotlin-maven-plugin构建的jar中使用Kotlin类 [英] Using Kotlin classes from jar built with kotlin-maven-plugin

查看:1058
本文介绍了从使用kotlin-maven-plugin构建的jar中使用Kotlin类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用kotlin-maven-plugin(v 1.2.21)构建了Java/Kotlin混合库.该库实际上是一个Spring Boot应用程序(v 1.5.9)

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)

现在,当我将其声明为另一个项目的依赖项时,我遇到了奇怪的问题: -我的IDE(Intellij)能够找到我需要的类:自动补全为我提出了这些类,并且我没有错误 -但是,当我尝试构建应用程序时,出现编译错误,说我要导入的包(以及类)不存在.

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.

当我在IDE中展开jar时,可以看到类存在于BOOT-INF/classes目录下的预期软件包中.

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.

所以我有点困惑……是否有特定的配置要放入kotlin-maven-plugin,以便生成的jar可以被其他人使用?

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 ?

谢谢

推荐答案

好的,实际上,它与Kotlin无关,但是一切与Spring Boot无关...

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

由于1.4.0版本之后的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>

这篇关于从使用kotlin-maven-plugin构建的jar中使用Kotlin类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆