我怎样才能加快Maven和Netbeans的速度

Spi*_*der 7 spring tomcat netbeans hibernate maven

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

不幸的是,每次我对课程进行更改时,我都需要重建.这意味着

  • 全部保存并编译
  • 运行所有测试
  • 建立一个大规模的战争
  • 从Tomcat取消部署
  • 从Tomcat重新部署
  • 启动应用程序(Spring = Zzzzzzz/Hibernate = Zzzzzzz)

这可能需要5分钟的时间来检查一个小的变化是否有所作为.也许我的方法不对?

请指教...

kda*_*bir 6

好吧,我也在进行类似的设置,所以这里是我的2美分.

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

    <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>
Run Code Online (Sandbox Code Playgroud)

现在,到项目Properties(右键单击项目)> Build> Compile> Compile on save和选择For both application and text execution.

也去Options> Miscellaneous> Maven>检查/选择Skip Tests for any build executions not directly related to testing,这样的测试只运行当你真正运行"测试".

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

  1. 当某些东西不起作用时,您仍然需要进行清理构建(例如,您删除了某些内容并且更改未反映)

  2. 保持运行很长时间可以给PermGen异常(空间不足),这是合理的,你总是可以使用jvm opts来增加内存

  3. 一旦习惯了这种设置,你就会讨厌在像jboss/websphere这样的容器上开发/测试项目