2016-03-24 15 views
4

私はオブジェクトに私のxmlをアンマーシャルしているjunitテストを持っていますうまく動作します!unmarhsal xml over maven

しかし、私がmavenコマンドを実行すると、mvn surefire-report:report -Pmytestsは、unmarhsal xmlをオブジェクトにすることはできません。私は

私のpom.xml

<?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.project</groupId> 
    <artifactId>automation</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0-SNAPSHOT</version> 


    <build> 
     <directory>target</directory> 
     <sourceDirectory>src/main/java</sourceDirectory> 
     <outputDirectory>target/classes</outputDirectory> 
     <finalName>AUTOMATION-01</finalName> 
     <testSourceDirectory>src/test/java/com/tests</testSourceDirectory> 
     <testOutputDirectory>target/test-classes</testOutputDirectory> 
     <resources> 
      <resource> 
       <directory>src/main/resources</directory> 
      </resource> 
     </resources> 


     <plugins> 

      <plugin> 
       <inherited>true</inherited> 
       <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.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.3</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
        <encoding>UTF-8</encoding> 
       </configuration> 
      </plugin> 

      <plugin> 
       <inherited>true</inherited> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-deploy-plugin</artifactId> 
       <configuration> 
        <updateReleaseInfo>true</updateReleaseInfo> 
       </configuration> 
      </plugin> 

      <plugin> 
       <artifactId>maven-clean-plugin</artifactId> 
       <version>3.0.0</version> 
       <configuration> 
        <filesets> 
         <fileset> 
          <directory>target</directory> 
         </fileset> 
        </filesets> 
       </configuration> 
      </plugin> 

     </plugins> 
    </build> 


    <profiles> 

     <profile> 
      <id>myTests</id> 
      <build> 
       <plugins> 
        <plugin> 
         <groupId>org.apache.maven.plugins</groupId> 
         <artifactId>maven-surefire-plugin</artifactId> 
         <version>2.15</version> 
         <configuration> 
          <encoding>UTF-8</encoding> 
          <argLine>-Dfile.encoding=UTF-8</argLine> 
          <groups>com.testgroups.myTestGroup</groups> 
          <redirectTestOutputToFile>true</redirectTestOutputToFile> 
         </configuration> 
        </plugin> 
       </plugins> 
      </build> 
     </profile> 

     </profiles> 

    <dependencies> 
     <dependency> 
      <groupId>javax.xml.ws</groupId> 
      <artifactId>jaxws-api</artifactId> 
      <version>2.2.11</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-io</groupId> 
      <artifactId>commons-io</artifactId> 
      <version>2.4</version> 
     </dependency> 
     <dependency> 
      <groupId>commons-lang</groupId> 
      <artifactId>commons-lang</artifactId> 
      <version>2.6</version> 
     </dependency> 
     <dependency> 
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.17</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.2.11</version> 
     </dependency> 
     <dependency> 
      <groupId>org.glassfish.jaxb</groupId> 
      <artifactId>jaxb-runtime</artifactId> 
      <version>2.2.11</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.xml.bind</groupId> 
      <artifactId>jaxb-api</artifactId> 
      <version>2.2.12</version> 
     </dependency> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.12</version> 
     </dependency> 
     <dependency> 
      <groupId>com.oracle</groupId> 
      <artifactId>ojdbc6</artifactId> 
      <version>11.2.0.3</version> 
      <scope>system</scope> 
      <systemPath>${project.basedir}/lib/ojdbc6.jar</systemPath> 
     </dependency> 
     <dependency> 
      <groupId>org.perf4j</groupId> 
      <artifactId>perf4j</artifactId> 
      <version>1.0</version> 
      <scope>system</scope> 
      <systemPath>${project.basedir}/lib/perf4j-0.9.16.jar</systemPath> 
     </dependency> 
     <dependency> 
      <groupId>org.gelfj</groupId> 
      <artifactId>gelfj</artifactId> 
      <version>1.0.1</version> 
      <scope>system</scope> 
      <systemPath>${project.basedir}/lib/gelfj-1.0.1.jar</systemPath> 
     </dependency> 
     <dependency> 
      <groupId>com.googlecode.json-simple</groupId> 
      <artifactId>json-simple</artifactId> 
      <version>1.1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.httpcomponents</groupId> 
      <artifactId>httpclient</artifactId> 
      <version>4.5.1</version> 
     </dependency> 
    </dependencies> 

</project> 

は、あなたがこの問題を解決するために私を助けてもらえNULLオブジェクトが例外なく ?

+0

にxmlファイルをコピーしようとします。質問にコピー貼りのエラーがありますか? – beresfordt

+0

はい、私のコピーの貼り付けエラーです。しかし、問題は異なっている –

答えて

0

Mavenは、リソースとテストリソースを区別します。たぶんあなたはマーシャリングされているxmlファイルをsrc/main/resourcesフォルダの下のどこかに置いていますか?

場合厥、あなたが `` タグを開いているが、何の対応する `` タグはありませんsrc/test/resources