maven编译在NetBeans中不生成输出

时间:2017-06-21 13:57:33

标签: java maven netbeans netbeans-8

我在NetBeans中创建了一个新的基于maven的java项目。当我没有添加任何依赖项时,一切正常但是当我使用下面给出的pom文件(来自不同的项目,类似)时,运行屏幕直接显示BUILD SUCCESS而不列出任何System.out.print语句或记录器的任何输出。

  

pom文件

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

    <properties>
    <ctakes.version>4.0.0</ctakes.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <verbose>true</verbose>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <configuration>
                  <verbose>true</verbose>
                  <executable>java</executable>
                  <arguments>
                    <argument>-Xms512m</argument>
                    <argument>-Xmx512m</argument>
                    <argument>-XX:NewRatio=3</argument>
                    <argument>-XX:+PrintGCTimeStamps</argument>
                    <argument>-XX:+PrintGCDetails</argument>
                    <argument>-Xloggc:gc.log</argument>
                    <argument>-classpath</argument>
                    <classpath/>
                    <!--<argument>com.redstack.App</argument>-->
                  </arguments>
                </configuration>
            </plugin>
        </plugins>
        </pluginManagement>
    </build>

    <!-- Adding cTAKES Dependecies here -->
    <dependencies>

      <!--   ctakes-core contains core classes, utilities, and commonly-used readers, writers and analysis engines.  -->
      <!--   ctakes-core will pull from maven central basic requirements: uima, uimafit, cleartk, type system ...   -->
      <!--   All other modules require ctakes-core.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-core</artifactId>
         <version>${ctakes.version}</version>
      </dependency>

      <!--   ctakes-pos-tagger tags parts of speech for tokens in text.   -->
      <!--   ctakes-pos-tagger is required for ctakes-dictionary-lookup and ctakes-dictionary-lookup-fast.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-pos-tagger</artifactId>
         <version>${ctakes.version}</version>
      </dependency>

      <!--   ctakes-chunker chunks tokens with parts of speech into phrases.   -->
      <!--   ctakes-chunker is required for the old ctakes-dictionary-lookup.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-chunker</artifactId>
         <version>${ctakes.version}</version>
      </dependency>

      <!--   ctakes-lvg generates lexical variants of tokens in text.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-lvg</artifactId>
         <version>${ctakes.version}</version>
      </dependency>

      <!--   ctakes-dictionary-lookup-fast discovers concepts in text and normalizes them to standard codes.   -->
      <!--   ctakes-dictionary-lookup-fast is much improved over the original ctakes-dictionary-lookup.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-dictionary-lookup-fast</artifactId>
         <version>${ctakes.version}</version>
      </dependency>      

      <!--   ctakes-assertion contains rule-based and machine-learning engines to discover entity attributes.   -->
      <!--   attributes: polarity, uncertainty, history_of, conditional, generic, subject   -->
      <!--   ctakes-assertion discovers more attributes than the ctakes-ne-contexts module.   -->
      <!--   ctakes-assertion will add ctakes-constituency-parser and ctakes-dependency-parser modules.   -->
      <!--   ctakes-assertion module requires mitre libraries that are not in maven central.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-assertion</artifactId>
         <version>${ctakes.version}</version>
      </dependency>

      <!--   ctakes-ne-contexts contains rule-based engines to discover entity attributes.   -->
      <!--   attributes: polarity, status   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-ne-contexts</artifactId>
         <version>${ctakes.version}</version>
      </dependency>

      <!--   ctakes-drug-ner discovers Medications and related attributes such as strength, dosage, frequency, etc.-->
      <!--   ctakes-drug-ner will add ctakes-chunker, ctakes-lvg, ctakes-dictionary-lookup,
             ctakes-context-tokenizer, ctakes-ne-contexts modules.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-drug-ner</artifactId>
         <version>${ctakes.version}</version>
      </dependency>

      <!--   ctakes-ytex and ctakes-ytex-uima are a collection of ctakes extensions.   -->
      <!--   ctakes-ytex-uima will add ctakes-pos-tagger, ctakes-chunker, ctakes-lvg,
             ctakes-dictionary-lookup, ctakes-context-tokenizer, ctakes-constituency-parser,
             ctakes-dependency-parser, ctakes-assertion, ctakes-ne-contexts.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-ytex</artifactId>
         <version>${ctakes.version}</version>
      </dependency>


      <!--   ctakes-clinical-pipeline contributes very little on its own, but loads many other modules.   -->
      <!--   ctakes-temporal will add ctakes-preprocessor, ctakes-pos-tagger, ctakes-chunker, ctakes-lvg,
             ctakes-dictionary-lookup-fast, ctakes-context-tokenizer, ctakes-constituency-parser,
             ctakes-dependency-parser, ctakes-assertion, ctakes-ne-contexts, ctakes-drug-ner, ctakes-ytex-uima.    -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-clinical-pipeline</artifactId>
         <version>${ctakes.version}</version>
      </dependency>


      <!--   ctakes-relation-extractor can extract relations between entities such as location and degree.   -->
      <!--   ctakes-relation-extractor will add ctakes-pos-tagger, ctakes-chunker, ctakes-lvg,
             ctakes-dictionary-lookup, ctakes-context-tokenizer, ctakes-constituency-parser,
             ctakes-dependency-parser, ctakes-ne-contexts.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-relation-extractor</artifactId>
         <version>${ctakes.version}</version>
      </dependency>


      <!--   ctakes-temporal discovers entities, temporal expressions, temporal relations,
             and document-creation-time relativity.   -->
      <!--   ctakes-temporal will add ctakes-pos-tagger, ctakes-chunker, ctakes-lvg,
             ctakes-dictionary-lookup-fast, ctakes-context-tokenizer, ctakes-constituency-parser,
             ctakes-dependency-parser, ctakes-relation-extractor, ctakes-clinical-pipeline.   -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-temporal</artifactId>
         <version>${ctakes.version}</version>
      </dependency>


      <!--   ctakes-coreference discovers coreferent entities in text.   -->
      <!--   ctakes-coreference will add ctakes-constituency-parser, ctakes-dictionary-lookup, ctakes-assertion,
             ctakes-temporal and a large UMLS database.  -->
      <dependency>
         <groupId>org.apache.ctakes</groupId>
         <artifactId>ctakes-coreference</artifactId>
         <version>${ctakes.version}</version>
      </dependency>    

    </dependencies>
    <!-- End of cTAKES Dependencies -->

</project>
  

运行主文件时得到的输出:

cd C:\Users\tdas1006\Documents\NetBeansProjects\cda; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_131" cmd /c "\"\"C:\\Program Files\\NetBeans 8\\NetBeans 8.2\\java\\maven\\bin\\mvn.bat\" -Dexec.args=\"-classpath %classpath com.optum.cda.main.Test\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_131\\bin\\java.exe\" -Dexec.classpathScope=runtime -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:exec\""
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building cda 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ cda ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.353s
[INFO] Finished at: Thu Jun 22 01:41:42 IST 2017
[INFO] Final Memory: 11M/122M
[INFO] ------------------------------------------------------------------------

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

我找到了一个解决方案,但我真的不明白它为什么会起作用。也许有人可以指出。

我所做的是更改maven目标执行的参数(org.codehaus.mojo:exec-maven-plugin:exec)。以前它使用java来执行导致问题的类。当我切换到使用javaw而不是java作为可执行文件时,一切正常,我不知道为什么!

我更改了nbactions.xml文件以在目标中包含javaw。编辑过的文件:

<?xml version="1.0" encoding="UTF-8"?>
<actions>
        <action>
            <actionName>run</actionName>
            <packagings>
                <packaging>jar</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:exec</goal>
            </goals>
            <properties>
                <exec.args>-classpath %classpath ${packageClassName}</exec.args>
                <exec.executable>javaw</exec.executable>
            </properties>
        </action>
        <action>
            <actionName>run.single.main</actionName>
            <packagings>
                <packaging>*</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:exec</goal>
            </goals>
            <properties>
                <exec.args>-classpath %classpath ${packageClassName}</exec.args>
                <exec.executable>javaw</exec.executable>
                <exec.classpathScope>${classPathScope}</exec.classpathScope>
            </properties>
        </action>
        <action>
            <actionName>debug</actionName>
            <packagings>
                <packaging>jar</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
            </goals>
            <properties>
                <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args>
                <exec.executable>javaw</exec.executable>
                <jpda.listen>true</jpda.listen>
            </properties>
        </action>
        <action>
            <actionName>debug.single.main</actionName>
            <packagings>
                <packaging>*</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
            </goals>
            <properties>
                <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args>
                <exec.executable>javaw</exec.executable>
                <exec.classpathScope>${classPathScope}</exec.classpathScope>
                <jpda.listen>true</jpda.listen>
            </properties>
        </action>
        <action>
            <actionName>profile</actionName>
            <packagings>
                <packaging>jar</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
            </goals>
            <properties>
                <exec.args>-classpath %classpath ${packageClassName}</exec.args>
                <exec.executable>javaw</exec.executable>
            </properties>
        </action>
        <action>
            <actionName>profile.single.main</actionName>
            <packagings>
                <packaging>*</packaging>
            </packagings>
            <goals>
                <goal>process-classes</goal>
                <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
            </goals>
            <properties>
                <exec.args>-classpath %classpath ${packageClassName}</exec.args>
                <exec.executable>javaw</exec.executable>
                <exec.classpathScope>${classPathScope}</exec.classpathScope>
            </properties>
        </action>
    </actions>