![](/img/trans.png)
[英]Maven project is getting compiled by Eclipse Update Project but not by pom.xml?
[英]How to build project like Eclipse Clean on Maven pom.xml
我需要運行 Maven 項目的幫助。 我可以在 Eclipse 上運行該項目,我嘗試在 Jenkins CI 上部署/運行它,但沒有成功。
我使用自定義文件夾結構(不遵循默認值)制作了一個 Maven 項目。
下面是結構:
通過首先清理項目,我可以通過 Eclipse 成功運行該項目,我相信 Eclipse 會為我構建所有 java 文件。 下面是我通過 Eclipse 清理項目后的“目標”文件夾(不是 maven 清理)
但是,當我刪除“目標”文件夾的內容並運行 maven -clean 和 maven -install 時,我收到如下錯誤:
我相信這是因為我沒有在 pom.xml 上設置任何關於構建所有 java 類的內容。 然而我不知道該怎么做? 你能幫助我嗎? 現在避免改變結構。 謝謝
下面是 pom.xml
<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>bukalapak</groupId>
<artifactId>bukalapak</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.46.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.46.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- <resources>
<resource>
<directory>src/bukalapak</directory>
</resource>
</resources> -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<forkMode>never</forkMode>
<suiteXmlFiles>
<suiteXmlFile>testsuite/TestSuiteBukalapak.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
您可以使用maven-compiler-plugin 。 例子:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
如果不使用默認目錄結構,則必須適當配置源目錄。 在您的情況下,正確的配置是:
<build>
<sourceDirectory>src</sourceDirectory>
</build>
否則 Maven 將查看默認文件夾結構。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.