我有以下pom文件从XSD生成类文件。这些都包含在他生成的JAR文件中。我尝试在这个Eclipse项目中创建一个单元测试,它使用一个生成的文件,但在运行" mvn install"并且在导入包时,仍然无法解析包。我试图清理Eclipse项目并更新Maven。我解压缩了JAR文件,并在那里有类。
测试文件:
import gov.hhs.fha.nhinc.common.nhinccommonadapter.RespondingGatewayCrossGatewayQueryRequestType;
提取JAR文件:
mvn clean install
cd target
jar xvfz *.jar>
inflated: gov/hhs/fha/nhinc/common/nhinccommonadapter/RespondingGatewayCrossGatewayRetrieveResponseType.class
pom文件:
<?xml version="1.0"?>
<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>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<groupId>org.connectopensource</groupId>
<version>4.0.7</version>
<artifactId>CONNECTCommonTypesLib</artifactId>
<packaging>jar</packaging>
<name>CONNECT common types</name>
<scm>
<connection>scm:git:git@github.com:${git.username}/Common-Types.git</connection>
<developerConnection>scm:git:git@github.com:${git.username}/Common-Types.git</developerConnection>
<url>https://github.com/${git.username}/Common-Types</url>
<tag>4.0.7</tag>
</scm>
<developers>
</developers>
<prerequisites>
<maven>3.0.4</maven>
</prerequisites>
<licenses>
<license>
<name>CONNECT License Agreement</name>
<url>http://www.connectopensource.org/product/licensing</url>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.7-b53</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4</version>
<configuration>
<pushChanges>false</pushChanges>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb22-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<generateDirectory>${project.build.directory}/generated-sources/</generateDirectory>
<schemaDirectory>${basedir}/src/main/resources/schemas/</schemaDirectory>
<strict>${xjc.strict}</strict>
<schemaIncludes>
<include>nhinc/**/*.xsd</include>
<include>docs.oasis-open.org/**/*.xsd</include>
<include>ebRS/**/*.xsd</include>
<include>ihe/**/*.xsd</include>
<include>nhin/**/*.xsd</include>
<include>oasis/**/*.xsd</include>
<include>uddi/uddi_v3.xsd</include>
<include>uddi/uddi_v3custody.xsd</include>
<include>uddi/uddi_v3policy_instanceParms.xsd</include>
<include>uddi/uddi_v3subscriptionListener.xsd</include>
<include>uddi/uddi_v3subscription.xsd</include>
<include>www.w3.org/**/*.xsd</include>
<include>xmlsoap.org/**/*.xsd</include>
<include>Endpoint/**/*.xsd</include>
</schemaIncludes>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<testSource>1.6</testSource>
<testTarget>1.6</testTarget>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>apache-snapshots</id>
<name>Apache SNAPSHOT Repository</name>
<url>http://repository.apache.org/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<profiles>
<profile>
<id>linux</id>
<activation>
<os>
<name>linux</name>
</os>
</activation>
<properties>
<xjc.strict>false</xjc.strict>
</properties>
</profile>
</profiles>
</project>
目录结构:
/src/main/resources
/src/test/java
这似乎是Eclipse的问题,因为我能够运行&#34; mvn install&#34;从命令行,它已成功构建并运行测试。