【问题标题】:Do I have to build maven webapp project everytime i make changes into static files?每次我对静态文件进行更改时,我是否必须构建 maven webapp 项目?
【发布时间】:2016-08-23 05:22:56
【问题描述】:

我正在使用 JBOSS AS7.1,Eclipse Luna 进行开发。我的 eclipse 安装确实为 maven 安装了一个插件。

我已经使用 maven 命令行创建了我的 webapp 项目。

在我当前的设置中,我必须每次都使用mvn clean install 构建我的 maven 项目以进行所有更改,即使对于 HTML、CSS 等静态文件也是如此。

然后,我必须使用运行在http://localhost:9990/console 的 JBOSS 控制台部署生成的 WAR 文件。

我很确定一定有另一种方法可以做到这一点。当然,这确实需要很多时间。

请指导我可以采用哪些方法来加快开发速度。

【问题讨论】:

  • 我正在使用 JBOSS AS 7 服务器。
  • 没有。对 JBOSS 没有任何特殊需求。但作为开发人员,我更希望我的开发和测试环境相同。

标签: spring maven web-applications jboss7.x


【解决方案1】:

一个选项是jrebel。不过它不是免费的。

如果你没有绑定JBOSS,你可以使用spring boot。还支持自动重启(spring boot devtools)

【讨论】:

    【解决方案2】:

    您可以替换目标文件夹中的静态文件并启动构建以跳过compile 阶段。

    当只更新静态文件时,它将为您节省大量时间。

    这不是一个好习惯,但应该能让你实现目标。

    如何

    • 使用maven-clean-plugin 从目标文件夹中删除要替换的文件(否则它们不会被覆盖);
    • 如果您的静态文件不是您要复制的资源文件夹的唯一内容(或者您的静态文件根本不在 resources 文件夹中),请使用 resources 标签;
    • 使用maven-compiler-plugin 跳过编译阶段。

    自定义此配置文件(并将其与mvn clean install -P skip-compile 一起使用):

    <profile>
        <id>skip-compile</id>
        <build>
            <resources> <!-- optional -->
                <resource>
                    <directory>src/main/resources/META-INF</directory>
                    <targetPath>META-INF</targetPath>
                    <excludes>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                    <includes>
                        <include>**/*.html</include>
                        <include>**/*.css</include>
                    </includes>
                </resource>
            </resources>
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.0.0</version>
                    <configuration>
                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                        <filesets>
                            <fileset>
                                <directory>${project.build.outputDirectory}/META-INF</directory>
                                <excludes>
                                    <exclude>**/not_to_delete.xml</exclude>
                                </excludes>
                                <includes>
                                    <include>**/*.html</include>
                                    <include>**/*.css</include>
                                </includes>
                                <followSymlinks>false</followSymlinks>
                            </fileset>
                        </filesets>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>default-compile</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                            <configuration>
                                <skipMain>true</skipMain>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    

    【讨论】:

    • 在赏金结束 2 小时后接受答案... >.>
    猜你喜欢
    • 2016-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    • 2021-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多