简体   繁体   English

从使用kotlin-maven-plugin构建的jar中使用Kotlin类

[英]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). 我使用kotlin-maven-plugin(v 1.2.21)构建了Java / Kotlin混合库。 The lib is actually a Spring Boot app (v 1.5.9) 该库实际上是一个Spring Boot应用程序(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. 现在,当我将其声明为另一个项目的依赖项时,我遇到了奇怪的问题:-我的IDE(Intellij)能够找到我需要的类:自动补全为我提供了这些类,并且我没有错误-但是当我尝试时构建我的应用程序时,出现编译错误,提示我尝试导入的包(以及类)不存在。

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. 在IDE中扩展jar时,可以看到类存在于BOOT-INF / classes目录下的预期程序包中。

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-maven-plugin,以便生成的jar可以被其他人使用?

Thanks 谢谢

OK, so actually, it had nothing to do with Kotlin, but everything with Spring Boot... 好的,所以实际上,它与Kotlin无关,但是与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 由于此处说明 1.4.0版本之后Spring Boot中结构的变化,因此,如果要导入jar,现在需要添加此配置

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用kotlin-maven-plugin进行注释处理 - Annotation processing with kotlin-maven-plugin 生命周期配置未涵盖插件执行:org.jetbrains.kotlin:kotlin-maven-plugin:1.1.51:test-compile - Plugin execution not covered by lifecycle configuration: org.jetbrains.kotlin:kotlin-maven-plugin:1.1.51:test-compile Maven 无法解析 Kotlin Maven 插件 Z68995FCBF432492D1548D2DAC04 - Maven can't resolve the Kotlin Maven Plugin jar 使用 maven 构建的 jar 中缺少 Java 类 - Java classes missing from jar built with maven 如何使用 gradle maven-publish 插件和 Kotlin DSL 发布带有空 pom 的 shadow jar? - How to publish a shadow jar with an empty pom using gradle maven-publish plugin and Kotlin DSL? maven 程序集插件不包括我在内置 jar 中的类 - maven assembly plugin does not include my classes inside built jar 在 Java 中使用 Kotlin Value 类 - Using Kotlin Value classes in Java 使用Kotlin开发一个Eclipse插件 - Using Kotlin to develope an Eclipse plugin 在从 Maven 运行的测试中使用 Kotlin `ScriptEngine` 时获取 `ScriptException` - Getting `ScriptException` when using Kotlin `ScriptEngine` in tests run from Maven 使用Gradle链接到Kotlin的JVM asm定义的类 - Linking to JVM asm-defined classes from Kotlin using Gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM