我如何加快Maven和Netbeans [英] How can I speed up Maven and Netbeans

查看:75
本文介绍了我如何加快Maven和Netbeans的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Maven通过Netbeans构建了一个相当大的项目(包括Spring和Hibernate的相当大的堆栈)。



不幸的是,每当我做出改成班级,我需要重建。这意味着


  • 全部保存&编译

  • 运行所有测试

  • 构建大规模WAR

  • 从Tomcat取消部署

  • 从Tomcat重新部署

  • 启动应用程序(Spring = Zzzzzzz / Hibernate = Zzzzzzz)


这可能需要长达5分钟的时间来检查一个小小的变化是否有所不同。或许我有错误的做法?



请指教...

解决方案

<好吧,我也在做相当类似的设置,所以这里是我的2美分。

首先,使用Maven-Jetty Plugin来弄湿你的脚。使其扫描文件以进行更改,以便您不必为每个更改重建/部署整个项目。还要配置它以存储会话,以便在每次(自动)部署时都不必重新登录并进入更改前的状态:

 < plugin> 
< groupId> org.mortbay.jetty< / groupId>
< artifactId> maven-jetty-plugin< / artifactId>
< version> 6.1.24< / version>
<配置>
< stopPort> 9669< / stopPort>
< stopKey> myapp< / stopKey>
<! - 如果检测到更改,则每隔x秒重新部署,0不自动重新部署 - >
< scanIntervalSeconds> 3< / scanIntervalSeconds>
<连接器>
< connector implementation =org.mortbay.jetty.nio.SelectChannelConnector>
< port> 8080< / port>
< maxIdleTime> 60000< / maxIdleTime>
< / connector>
< / connectors>
< webAppConfig>
< contextPath> / myapp< / contextPath>
< sessionHandler implementation =org.mortbay.jetty.servlet.SessionHandler>
< sessionManager implementation =org.mortbay.jetty.servlet.HashSessionManager>
< storeDirectory> $ {project.build.directory} / sessions< / storeDirectory>
< / sessionManager>
< / sessionHandler>
< / webAppConfig>
< / configuration>
< / plugin>

现在,转到项目属性右击项目)> Build > 编译> 保存时编译并选择用于应用程序和文本执行



也请到选项> 杂项> Maven >并检查/选择跳过测试以获取与测试没有直接关系的任何生成执行,以便测试仅在您运行时运行实际上运行'测试'。

遵循这些简单的步骤,我可以快速编写和测试更改,无需重新部署。也就是说,我遇到了一些小问题/烦恼:


  1. 在某些情况下,您仍然需要进行清理构建不工作(例如,您删除了某些内容并且更改没有反映出来)

  2. 保持长时间运行可能会导致PermGen异常(空间不足)合理的,你可以使用jvm opts来增加内存。一旦你习惯了这种设置,你会讨厌在容器上开发/测试项目,比如jboss / websphere。


I have a rather large project (with quite a large stack including Spring and Hibernate) that I build through Netbeans using Maven.

Unfortunately, every time I make a change to a class, I need to rebuild. This means

  • Save All & Compile
  • Run all the tests
  • Build a Massive WAR
  • Undeploy from Tomcat
  • Redeploy from Tomcat
  • Start up the Application (Spring = Zzzzzzz / Hibernate = Zzzzzzz)

This can take up to 5 minutes to check if a small change made a difference. Perhaps I have the wrong approach?

Please advise...

解决方案

Okay, I'm also working on quite similar setup so here are my 2 cents.

First off, get your feet wet with Maven-Jetty Plugin. Make it scan the files for changes so that you don't have to rebuild/deploy the entire project for every changes. Also configure it to store session so that with every (automatic) deploy you don't have to relogin and get to the state you were at before making changes:

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>6.1.24</version> 
        <configuration>
            <stopPort>9669</stopPort>
            <stopKey>myapp</stopKey>
            <!-- Redeploy every x seconds if changes are detected, 0 for no automatic redeployment -->
            <scanIntervalSeconds>3</scanIntervalSeconds>
            <connectors>
                <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                    <port>8080</port>
                    <maxIdleTime>60000</maxIdleTime>
                </connector>
            </connectors>
            <webAppConfig>
                <contextPath>/myapp</contextPath>
                <sessionHandler implementation="org.mortbay.jetty.servlet.SessionHandler">
                    <sessionManager implementation="org.mortbay.jetty.servlet.HashSessionManager">
                        <storeDirectory>${project.build.directory}/sessions</storeDirectory>
                    </sessionManager>
                </sessionHandler>
            </webAppConfig>
        </configuration>
    </plugin>

Now, go to project Properties (by right clicking project)> Build > Compile > Compile on save and select For both application and text execution.

Also go to Options > Miscellaneous > Maven > and check/select Skip Tests for any build executions not directly related to testing, so that test are only run when you actually Run 'Test'.

Following these simple steps, I can code and test changes live, quickly and without needing a redeploy. That said, I have faced a few minor issues/annoyances:

  1. You still have to clean-build at times when something does not work (for example, you deleted something and changes do not reflect)

  2. Keeping it running long time can give PermGen exception (Out of space), which is reasonable and you can always increase the memory using jvm opts

  3. you will hate to develop/test projects on containers like jboss/websphere once you get used to this setup

这篇关于我如何加快Maven和Netbeans的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆