情况如下。我在java / selenium / maven项目中。我没有测试类,因此Project-> Properties-> Java Build Path-> Source中只有两个“构建路径上的源文件夹”是:
src / main / java和src / main / resources。此外,src / main / resources“Excluded”设置为(None)。
我做Maven /更新项目......
现在由于某种原因,src / test / java已被添加并且缺失,并且src / main / resouces已更改为**,这将排除该目录中的所有文件。
我做了更改以重做所有这些,保存,执行Maven / Update Project,然后再回到这些更改。什么不断改变我的项目的.classpath?
编辑以在。之前和之后添加.settings文件。
在执行Maven->更新项目之前:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="src/main/resources/db2jcc_license.jar"/>
<classpathentry kind="lib" path="src/main/resources/db2jcc4.jar"/>
<classpathentry kind="lib" path="src/main/resources/ojdbc6.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
执行Maven-&gt;更新项目后:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="src/main/resources/db2jcc_license.jar"/>
<classpathentry kind="lib" path="src/main/resources/db2jcc4.jar"/>
<classpathentry kind="lib" path="src/main/resources/ojdbc6.jar"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
注意:从问题中添加了POM.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.this.ebusiness</groupId>
<artifactId>test-automation-framework</artifactId>
<version>LOCALBUILD</version>
<packaging>jar</packaging>
<name>Test Automation Framework</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-safari-driver</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency>
</dependencies>
答案 0 :(得分:1)
在Eclipse中,&#34; Maven - 更新项目......&#34;命令指示Eclipse根据.classpath
更新自己的项目文件(pom.xml
和其他项目)。它不是一个真正的Maven命令。您将看到的修改是由Eclipse添加的,基于Java / Maven项目的典型布局。我认为这是由maven2Nature
中maven2Builder
或.project
的存在所控制的。
你实际上没有说明这个问题,所以我不确定你为什么要改变它。但您可能会发现这些答案很有用:
答案 1 :(得分:0)
我们在这里有两个问题:
1)如果您正在使用maven,那么您不应该修改项目的.classpath或设置文件,因为这将由eclipse使用m2e插件进行维护。
这就是当您使用“maven =&gt; update project”时,您的项目文件从maven模板更新的原因。
2)使用maven是个好主意。 Maven介绍了项目的一些模板。因此,如果您使用maven,则必须接受一些特定于maven的约定。
此约定在maven项目页面上描述。
你可以通过覆盖maven super pom来覆盖这些约定。
见这里: here.
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
和
<testResources>
<testResource>
<directory>${project.basedir}/src/test/resources</directory>
</testResource>
</testResources>