我在maven中有项目。这是主要的pom.xml:
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>pl.derp</groupId> <artifactId>parent</artifactId> <packaging>pom</packaging> <version>1.0.0-SNAPSHOT</version> <modules> <module>server</module> <module>shared</module> <module>web</module> </modules> <properties> <gwtVersion>2.7.0</gwtVersion> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <tomcat.webport>8083</tomcat.webport> <tomcat.ajpport>8182</tomcat.ajpport> <tomcat.context>/parent</tomcat.context> <hibernate.version>4.3.7.Final</hibernate.version> <mysql.connector.version>5.1.21</mysql.connector.version> <slf4j.version>1.6.4</slf4j.version> <spring.version>3.0.5.RELEASE</spring.version> <guice.version>3.0</guice.version> </properties> <dependencies> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <version>${gwtVersion}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>${gwtVersion}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.0.0.GA</version> <classifier>sources</classifier> <scope>test</scope> </dependency> <!-- DB related dependencies --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.connector.version}</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId> <version>3.12.1.GA</version> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.182</version> </dependency> <!-- Logging --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <!-- Custom formats --> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.5</version> </dependency> <dependency> <groupId>org.jadira.usertype</groupId> <artifactId>usertype.extended</artifactId> <version>3.2.0.GA</version> </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-taglibs</artifactId> <version>${spring.version}</version> </dependency> <!-- Tests --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency> </dependencies> <build> <defaultGoal>clean install tomcat7:run-war-only</defaultGoal> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>${gwtVersion}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> </plugin> <!-- IDE --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.7</version> <!-- Note 2.8 does not work with AspectJ aspect path --> <configuration> <downloadSources>true</downloadSources> <downloadJavadocs>false</downloadJavadocs> <wtpversion>2.0</wtpversion> <additionalBuildcommands> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.google.gdt.eclipse.core.webAppProjectValidator</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>com.google.gwt.eclipse.core.gwtProjectValidator</name> <arguments> </arguments> </buildCommand> </additionalBuildcommands> <additionalProjectnatures> <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature> </additionalProjectnatures> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> <configuration> <path>${tomcat.context}</path> <port>${tomcat.webport}</port> <ajpPort>${tomcat.ajpport}</ajpPort> <systemProperties> <JAVA_OPTS>-XX:MaxPermSize=256m</JAVA_OPTS> </systemProperties> </configuration> </plugin> </plugins> </build> </project>
我正在使用tomcat7-maven-plugin,您可以在pom.xml中看到。
tomcat7-maven-plugin
要启动服务器,我使用命令: maven clean install tomcat7:run-war-only
maven clean install tomcat7:run-war-only
但是不幸的是,当我对 服务器端/层代码 进行任何更改时,我必须停止服务器并再次运行它,这需要很多时间,原因是:测试运行,完全编译,所有排列编译(这是gwt应用程序,因此为每个Web浏览器将Java代码编译为js代码)…
进行一些更改后,如何在运行时设置自动代码替换/热交换,而不必重新启动并重新编译项目?
我会加快我的开发过程。
请给我一些帮助。
我想花时间最长的是GWT并发症。如果您使用单个浏览器进行所有开发,则可以告诉GWT仅编译该浏览器的排列。查看此问题和已接受的答案以了解操作方法。那应该减少您的构建时间。
另外,您可以告诉Maven跳过测试。我实际上不建议您这样做,但是如果您确实确定更改不重要,或者不涉及Java代码,请使用Maven开关-DskipTests
-DskipTests
如果更改仅涉及HTML,CSS,JS,JSP等资源,则可以直接将它们直接复制到$ tomcat_home / webapps / yourapp,Tomcat将选择它们,不需要构建。注意始终在源代码中始终具有最新版本。
最后,Tomcat插件不需要重新启动Tomcat。尝试
mvn tomcat7:redeploy