Kotlin无法使用Eclipse Workspace Resolution [英] Kotlin not working with Eclipse Workspace Resolution

查看:126
本文介绍了Kotlin无法使用Eclipse Workspace Resolution的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Maven的Web应用程序,具有多个本地" Maven依赖项(即,这些依赖项本身就是与主应用程序在同一Eclipse工作区中维护的项目).

I have a Maven-based webapp with multiple "local" Maven dependencies (i.e. the dependencies are themselves projects that are maintained in the same Eclipse workspace as the main app).

我最近将Java的一种依赖关系重写为Kotlin.以下是Kotlin项目pom.xml的相关内容:

I recently rewrote one of the dependencies from Java to Kotlin. Here are the relevant bits from the Kotlin project's pom.xml:

<properties>
    <kotlin.version>1.3.50</kotlin.version>
    <project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
    <project.reporting.outputEncoding>ISO-8859-1</project.reporting.outputEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>${kotlin.version}</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.module</groupId>
        <artifactId>jackson-module-kotlin</artifactId>
        <version>2.9.9</version>
    </dependency>
</dependencies>

<build>
    <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>

    <plugins>
        <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <version>${kotlin.version}</version>
            <executions>
                <execution>
                    <id>compile</id>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <goals>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

当我尝试在Eclipse中的Tomcat中启动应用程序时,出现错误:

When I try to start the application in Tomcat inside Eclipse I get the error:

22:40:22 SEVERE: Context initialization failed
[...]
Caused by: java.lang.NoClassDefFoundError: ... (one of my classes from the new project)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1363)

我已经执行了许多故障排除步骤,并且毫无疑问地确定问题是由在依赖项目中使用Kotlin引起的,即,如果我将Kotlin项目还原到原始Java项目,一切都会再次起作用.

I have executed a number of troubleshooting steps and determined beyond any doubt that the problem is caused by having Kotlin in the dependency project, i.e. if I restore the Kotlin project to the original Java project, everything works again.

如何使用最新版本的Eclipse,Kotlin,Maven,Tomcat和m2e-wtp来解决此问题?

推荐答案

临时工作环境

我可以通过进入 Project菜单-> Maven->禁用工作区分辨率" ,然后手动转到每个依赖项项目并执行 Maven->安装,使该应用程序再次运行. .

I can get the app to work again by going Project menu -> Maven -> "Disable Workspace Resolution" and then manually going to each dependency project and doing a Maven -> install.

这是非常不令人满意的,因为在禁用工作空间解析"后,许多开发人员的生产力功能都丢失了. 因此,我将暂时保留该问题,并提供赏金,以期提供更永久的解决方案.

This is quite unsatisfactory as a lot of developer productivity features are lost when Workspace Resolution is disabled. So I'll keep the question open for now and offer a bounty in the hopes of a more permanent fix.

这篇关于Kotlin无法使用Eclipse Workspace Resolution的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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