我使用https://github.com/jottinger/owlapi-tutorial作为基础构建此maven文件,用于OWL ontology API:
<?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>
<!-- Downloaded from https://github.com/jottinger/owlapi-tutorial -->
<groupId>.</groupId>
<artifactId>TestJava</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>[4.0.2,4.9.9)</version>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-rio</artifactId>
<version>[4.0.2,4.9.9)</version>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>jfact</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>[6.9.8,)</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-rio</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>jfact</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<scriptSourceDirectory>${basedir}/src</scriptSourceDirectory>
<testSourceDirectory>${basedir}/src</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
使用此文件,我希望具有以下结构:
├── pom.xml
└── src
└── ClassTest.java
而不是https://github.com/jottinger/owlapi-tutorial上的默认结构:
├── pom.xml
└── src
└── test
└── java
└── com
└── autumncode
└── owlapi
└── ontology
└── ClassTest.java
但是,在我使用http://maven.apache.org/pom.html#Build_Element更改上面的pom.xml
文件后,它会显示错误:
$ mvn test -e -X
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T16:39:06-03:00)
Maven home: D:\User\Documents\apache_marven\maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_65\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "x86", family: "windows"
...
[INFO] 5 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.184 s
[INFO] Finished at: 2017-05-13T21:57:39-03:00
[INFO] Final Memory: 16M/40M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project TestJava: Compilation failure: Compilation failure:
[ERROR] /D:/owlapi/src/ClassTest.java:[2,18] package org.testng does not exist
[ERROR] /D:/owlapi/src/ClassTest.java:[3,30] package org.testng.annotations does not exist
[ERROR] /D:/owlapi/src/ClassTest.java:[5,25] package org.testng does not exist
[ERROR] /D:/owlapi/src/ClassTest.java:[9,10] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class ClassTest
[ERROR] /D:/owlapi/src/ClassTest.java:[12,9] cannot find symbol
[ERROR] symbol: method assertTrue(boolean)
[ERROR] location: class ClassTest
[ERROR] -> [Help 1]
对于文件src/ClassTest.java
中的以下源代码:
import org.testng.Assert;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
public class ClassTest
{
@Test
public void testAddClassesSimple()
{
assertTrue( true );
}
}
为了简单起见,我从上面的代码中删除了OWL导入,因为问题似乎只出现在testng
框架中。
上面的pom.xml
有什么问题,它对testng
不再适用于我的源文件具有以下结构:
├── pom.xml
└── src
└── ClassTest.java