這是情況。我在一個java/selenium/maven項目中。我沒有測試類,因此項目 - >屬性 - > Java構建路徑 - >源中僅有兩個「構建路徑上的源文件夾」是:使用Eclipse,東西不斷添加src/test/java到類路徑
src/main/java和src/main/resources。另外,src/main/resources「Excluded」被設置爲(None)。
我做一個Maven /更新項目...
現在出於某種原因的src/test/java下已添加和缺失,和src /主/ resouces已更改爲**,排除一切該目錄中的文件。
我做了更改,重做所有這些,保存,做一個Maven/Update項目,並再次回到這些更改。什麼讓我的項目更改我的.classpath?
編輯在添加.settings文件之前和之後。
執行Maven->更新項目之前:從問一個問題添加了pom.xml中:
<?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>
注:
<?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->更新項目後
<?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>
一個大問題是它加入**到/ src目錄/主/資源,然後不包括這些文件的排除列表在生成的jar文件中,它不起作用。另一個問題是它不能成功構建,因爲它期望存在一個/ src/main/test目錄,這在我的項目中不存在。因此,jar不會被創建,依賴於這個框架的其他項目將不會生成或運行。 – GregMa
您正在將'.classpath'(這隻對Eclipse很重要)與Maven POM混淆。排除'**'僅影響Eclipse內部構建器的類路徑。它不排除在使用例如JAR文件構建時包含在JAR中的資源。 'maven install'。 – TheCoolah
至於缺少'/ src/main/test'搞砸你的構建,只需添加一個空目錄,Eclipse就會很開心。這只是Eclipse期望的目錄結構。我不知道這個解決方法。 – TheCoolah