2012-03-15 40 views
0

我目前在Netbeans中有一个Maven应用程序。由于我需要在我的项目中使用正则表达式,因此我将以下类添加到了我的一个包中:http://docs.oracle.com/javase/tutorial/essential/regex/test_harness.htmlNetbeans with Maven - 奇怪的类行为

我更改了所有使用System.out和BufferedReader的输入/输出语句。当我从一个新项目运行这个课程时,该课程按预期工作。但是,当我将它添加到我的Maven项目后,我看不到以下输出:

NetBeans:执行'/ usr/share/maven2/bin/mvn -Dexec.classpathScope = runtime -Dexec.args = -classpath%classpath MySource.RegexTestHarness -Dexec.executable =/home/gowri/jdk1.6.0_20/bin/java -Dnetbeans.execution = true过程类org.codehaus.mojo:exec-maven-plugin:1.1.1:exec' NetBeans :JAVA_HOME = /家庭/ gowri/jdk1.6.0_20

扫描的项目...


大厦crawler4j 任务段:工艺类,org.codehaus .mojo:EXEC-行家-插件:1.1.1:EXEC]


[实施者:强制]

[资源:资源]

使用 'UTF-8' 编码复制过滤资源。

复印2个资源

[编译器:编译]

源文件编译到/ home/gowri/WORKSPACE/yasserg-crawler4j-7b8bf91 /目标/类

[EXEC:EXEC]

任何人都可以告诉我为什么会发生这种情况?我确信这个类是唯一一个带有main()函数的类,我点击“运行文件”而不是“运行项目”。

谢谢:)

编辑:我刚刚意识到的东西,当我将所有的是System.out.print()语句为System.out.println(),只有这样我可以看到正确的输出。任何想法为什么?

回答

2

问题似乎是在使用Netbeans中的maven时,输出窗口中分离的System.in或System.out,如issue中指出的那样。尝试将当前项目目录下的nbactions.xml文件中的exec-maven-plugin更新为1.2,此错误已在此新版本中得到解决。

要做到这一点与UI,去项目 - >属性 - >动作 - > 在行动: “工艺类组织:通过主(), 更改excecute目标,这样的事情 运行文件.codehaus.mojo:EXEC-Maven的插件:1.2:EXEC”

这样做之后,你的nbactions.xml应该有一个动作标签,它看起来像:

<action> 
     <actionName>run.single.main</actionName> 
     <goals> 
      <goal>process-classes</goal> 
      <goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal> 
     </goals> 
     <properties> 
      <exec.classpathScope>${classPathScope}</exec.classpathScope>     
      <exec.args>-Djava.library.path="${project.build.directory}/lib" -classpath %classpath ${packageClassName}</exec.args> 
      <exec.executable>java</exec.executable> 
     </properties> 
    </action> 
    <action> 
     <actionName>debug.single.main</actionName> 
     <goals> 
      <goal>process-classes</goal> 
      <goal>org.codehaus.mojo:exec-maven-plugin:1.2:exec</goal> 
     </goals> 
     <properties> 
      <exec.classpathScope>${classPathScope}</exec.classpathScope> 
      <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args> 
      <jpda.listen>true</jpda.listen> 
      <jpda.stopclass>${packageClassName}</jpda.stopclass> 
      <exec.executable>java</exec.executable> 
     </properties> 
    </action> 
+0

嘿嘿,谢谢! :) – arya 2012-03-16 14:13:41