Eclipse,Scala& Maven - 类文件不生成 [英] Eclipse, Scala & Maven - Class files are not generating

查看:141
本文介绍了Eclipse,Scala& Maven - 类文件不生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将eclipse中的scala项目转换为使用Maven(简单地通过右键单击项目并配置Maven构建),创建了pom.xml,添加了正确的依赖关系,它从maven仓库中提取了需要的jar,但是每当我尝试编译I不要在target\classes文件夹中看到生成的类文件。但是,我看到实际的源代码是在目标\class文件夹下的相应目录中的scala文件。我不知道为什么在target\classes文件夹中复制源文件。另一个更重要的是,如果我在eclipse中打开个别scala文件并进行一些代码更改,那么它会自动构建该类文件,但是我有1000多个scala文件,所以不是一个可行的选择。



我尝试过所有选项,如Eclipse - Clean&构建,但没有任何作用,我尝试甚至使用eclipse中的maven构建,但它总是出现这个消息没有编译 - 所有类都是最新的,我清理了目标目录,但仍然是一个问题。



感谢在这方面的任何帮助。



提前感谢



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

  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.xsdxmlns = 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>从不< / 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\\\
otmaven\src< / sourceDirectory>
< scriptSourceDirectory> C:\projectsomu\\\
otmaven\src\main\scripts< / scriptSourceDirectory>
< testSourceDirectory> C:\projectsomu\\\
otmaven\src\test\java< / testSourceDirectory>
< outputDirectory> C:\projectsomu\\\
otmaven\target\classes< / outputDirectory>
< testOutputDirectory> C:\projectsomu\\\
otmaven\target\test-classes< / testOutputDirectory>
< resources>
< resource>
< directory> C:\projectsomu\\\
otmaven\src< / directory>
< excludes>
< exclude> ** / *。java< / exclude>
< / excludes>
< / resource>
< / resources>
< testResources>
< testResource>
< directory> C:\projectsomu\\\
otmaven\src\test\resources< / directory>
< / testResource>
< / testResources>
< directory> C:\projectsomu\\\
otmaven\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>
<执行>
< 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>
<执行>
< 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>
<执行>
< 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>
<执行>
< 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>
<执行>
< 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>
<执行>
< 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>
<执行>
< 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>
<执行>
< execution>
< id> default-site< / id>
< phase> site< / phase>
< goals>
< goal> site< / goal>
< / goals>
< configuration>
< outputDirectory> C:\projectsomu\\\
otmaven\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\\\
otmaven\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\\\
otmaven\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\\\
otmaven\target\site< / outputDirectory>
< / reporting>
< / project>


解决方案

应该将以下插件添加到您的maven配置中( pom.xml )并重新配置项目。

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

还应该从其更新站点


I converted my scala project in eclipse to use Maven (simply by right clicking on project and Configure Maven build), this created pom.xml, added right dependency which pulled up required jars from maven repository but whenever i try to compile I don't see class file generating in target\classes folder. However, i see actual source code which is scala files in respective directory under target\classes folder. I am not sure why it is copying source files in target\classes folder.

Another wierd thing, is if i open individual scala file in eclipse and do some code changes, then it automatically builds that class file, however i have 1000+ scala files, so not a feasible option.

I tried all options such as Eclipse - Clean & Build, but nothing works, i tried even using maven build inside eclipse but it always comes up with this message "Nothing to compile - all classes are up to date", i cleaned up my target directory but still an issue.

I would appreciate any help in this regard.

Thanks in advance

I am using Scala Eclipse IDE -Scala IDE build of Eclipse SDK Build id: 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>

解决方案

You should add the following plugin to your maven configuration (pom.xml) and reconfigure the project.

<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>

You should also add the m2e-scala plugin from its update site.

这篇关于Eclipse,Scala&amp; Maven - 类文件不生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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