Copyright © 2022-2024 aizws.net · 网站版本: v1.2.6·内部版本: v1.23.3·
页面加载耗时 0.00 毫秒·物理内存 56.5MB ·虚拟内存 1300.5MB
欢迎来到 AI 中文社区(简称 AI 中文社),这里是学习交流 AI 人工智能技术的中文社区。 为了更好的体验,本站推荐使用 Chrome 浏览器。
NetBeans 6.7 及更新的版本已经内置了 Maven。对于以前的版本,可在插件管理中心获取 Maven 插件。此例中我们使用的是 NetBeans 6.9。 关于 NetBeans 的一些特性如下:
目前为止,你已经可以在 NetBeans 里看到 Maven 项目了。看一下consumerBanking 项目的 Libraries 和 Test Libraries. 你可以发现 NetBeans 已经将 Maven 所依赖的都添加到了它的构建路径里了。
好了,我们来使用 NetBeans 的编译功能来构建这个 Maven 项目
Maven 将会开始构建该项目。你可以在 NetBeans 的终端里查看输出的日志信息:
NetBeans: Executing 'mvn.bat -Dnetbeans.execution=true clean install' NetBeans: JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21 Scanning for projects... ------------------------------------------------------------------------ Building consumerBanking task-segment: [clean, install] ------------------------------------------------------------------------ [clean:clean] [resources:resources] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! skip non existing resourceDirectory C:\MVN\consumerBanking\src\main\resources [compiler:compile] Compiling 2 source files to C:\MVN\consumerBanking\target\classes [resources:testResources] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! skip non existing resourceDirectory C:\MVN\consumerBanking\src\test\resources [compiler:testCompile] Compiling 1 source file to C:\MVN\consumerBanking\target\test-classes [surefire:test] Surefire report directory: C:\MVN\consumerBanking\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.companyname.bank.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [jar:jar] Building jar: C:\MVN\consumerBanking\target\consumerBanking-1.0-SNAPSHOT.jar [install:install] Installing C:\MVN\consumerBanking\target\consumerBanking-1.0-SNAPSHOT.jar to C:\Users\GB3824\.m2\repository\com\companyname\bank\consumerBanking\ 1.0-SNAPSHOT\consumerBanking-1.0-SNAPSHOT.jar ------------------------------------------------------------------------ BUILD SUCCESSFUL ------------------------------------------------------------------------ Total time: 9 seconds Finished at: Thu Jul 19 12:57:28 IST 2012 Final Memory: 16M/85M ------------------------------------------------------------------------
现在,右键点击 App.java 文件。选择 Run File 选项。你可以在终端看到如下结果:
NetBeans: Executing 'mvn.bat -Dexec.classpathScope=runtime -Dexec.args=-classpath %classpath com.companyname.bank.App -Dexec.executable=C:\Program Files\Java\jdk1.6.0_21\bin\java.exe -Dnetbeans.execution=true process-classes org.codehaus.mojo:exec-maven-plugin:1.1.1:exec' NetBeans: JAVA_HOME=C:\Program Files\Java\jdk1.6.0_21 Scanning for projects... ------------------------------------------------------------------------ Building consumerBanking task-segment: [process-classes, org.codehaus.mojo:exec-maven-plugin:1.1.1:exec] ------------------------------------------------------------------------ [resources:resources] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! skip non existing resourceDirectory C:\MVN\consumerBanking\src\main\resources [compiler:compile] Nothing to compile - all classes are up to date [exec:exec] Hello World! ------------------------------------------------------------------------ BUILD SUCCESSFUL ------------------------------------------------------------------------ Total time: 1 second Finished at: Thu Jul 19 14:18:13 IST 2012 Final Memory: 7M/64M ------------------------------------------------------------------------
Maven IntelliJ:IntelliJ IDEA 已经内建了对 Maven 的支持。我们在此例中使用的是 IntelliJ IDEA 社区版 11.1。IntelliJ IDEA 的一些特性列出如下:可以通过 IntelliJ IDEA 来运行 Maven 目标。可以在 IntelliJ IDEA 自己的终端里查看 Maven 命令的输出结果。可以在 IDE 里更新 Maven 的依赖关系。