gpt4 book ai didi

Eclipse、Scala 和 Maven - 未生成类文件

转载 作者:行者123 更新时间:2023-12-02 10:17:57 24 4
gpt4 key购买 nike

我在 Eclipse 中将我的 scala 项目转换为使用 Maven(只需右键单击项目并配置 Maven 构建),这创建了 pom.xml,添加了正确的依赖项,从 Maven 存储库中提取所需的 jar,但每当我尝试编译时,我在 target\classes 文件夹中看不到生成的类文件。但是,我看到实际的源代码是 target\classes 文件夹下相应目录中的 scala 文件。我不确定为什么它要复制 target\classes 文件夹中的源文件。

另一个奇怪的事情是,如果我在 Eclipse 中打开单个 scala 文件并进行一些代码更改,那么它会自动构建该类文件,但是我有 1000 多个 scala 文件,所以不是一个可行的选择。

我尝试了所有选项,例如 Eclipse - Clean & Build,但没有任何效果,我什至尝试在 Eclipse 内使用 maven build,但它总是出现此消息“无需编译 - 所有类都是最新的”,我清理了我的目标目录,但仍然是一个问题。

我将不胜感激在这方面的任何帮助。

提前致谢

我正在使用 Scala Eclipse IDE-Eclipse SDK 的 Scala IDE 构建版本号:3.0.4-2.11-20140520-1158-Typesafe

Content of Pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>notmaven</groupId>
<artifactId>notmaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>C:\projectsomu\notmaven\src</sourceDirectory>
<scriptSourceDirectory>C:\projectsomu\notmaven\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>C:\projectsomu\notmaven\src\test\java</testSourceDirectory>
<outputDirectory>C:\projectsomu\notmaven\target\classes</outputDirectory>
<testOutputDirectory>C:\projectsomu\notmaven\target\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>C:\projectsomu\notmaven\src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>C:\projectsomu\notmaven\src\test\resources</directory>
</testResource>
</testResources>
<directory>C:\projectsomu\notmaven\target</directory>
<finalName>notmaven-0.0.1-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.3</source>
<target>1.2</target>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>1.3</source>
<target>1.2</target>
</configuration>
</execution>
</executions>
<configuration>
<source>1.3</source>
<target>1.2</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>C:\projectsomu\notmaven\target\site</outputDirectory>
</reporting>
</project>

最佳答案

should add将以下插件添加到您的 Maven 配置 (pom.xml) 并重新配置项目。

<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

should also add m2e-scala 插件来自其 update site .

关于Eclipse、Scala 和 Maven - 未生成类文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28047662/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com