【发布时间】:2015-10-20 09:19:21
【问题描述】:
我在运行 maven 项目方面需要帮助。我可以在 Eclipse 上运行该项目,我尝试在 Jenkins CI 上部署/运行它但没有成功。
我做了一个自定义文件夹结构的maven项目(不遵循默认)。
结构如下:
我可以通过 Eclipse 成功运行项目,方法是首先清理项目,我相信 Eclipse 会为我构建所有 java 文件。下面是我通过 Eclipse(不是 maven clean)清理项目后的“目标”文件夹的样子
但是,当我删除 'target' 文件夹的内容并运行 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>
【问题讨论】:
-
为什么不使用标准布局?!
-
@SilviuBurcea 增加可读性:(
-
不是一个很好的理由,因为默认的 maven 布局广为人知,所以我会说这是最好的......不要使用你自己的......这会给你带来如此多的配置在 Maven 中是错误的方式。