二.配置简单的嵌入式jetty

修改类文件,类加载器就能重新加载修改过的类,测试就方便了,在开发web应用的时候,这样做似乎不是件容易事.tomcat maven组件会把应用打成war包,再上传到tomcat,重新部署再测试,虽然看起来一切都是自动化过程,当jar包又多又大时,你会感觉到这组件很忙,或许因为如此,有些人选择了jetty maven组件,jetty不用打成war包,直接从输出目录重新加载类,看起来要优雅点.当我们用gradle,jetty组件稳定但不支持servlet3,gretty不稳定...以后gradle会好的,相信总有一天!
maven和gradle的项目标准目录结构是相似的,如下:
src/main/java Application/Library sources
src/main/resources Application/Library resources
src/main/filters Resource filter files
src/main/config Configuration files
src/main/scripts Application/Library scripts
src/main/webapp Web application sources
src/test/java Test sources
src/test/resources Test resources
src/test/filters Test resource filter files
src/it Integration Tests (primarily for plugins)
src/assembly Assembly descriptors
src/site Site
LICENSE.txt Project's license
NOTICE.txt Notices and attributions required by libraries that the project depends on
README.txt Project's readme
而两者编译输出目录有差别,但基本不存在不便.
和前篇文件一样,选用了<<gradle的war插件>>简单开发的web应用来测试.没有找到tomcat方便的API设置额外的类路径.下文主要以jetty来实现这个嵌入式jetty

1.再新建一个gradle项目,build.gradle如下:

apply plugin: 'java'
sourceCompatibility = 1.7
version = '1.0'
repositories {
    mavenCentral()
}
dependencies {
    compile("org.eclipse.jetty:jetty-util-ajax:9.2.1.v20140609")
    compile("org.eclipse.jetty:jetty-deploy:9.2.1.v20140609")
    compile("org.eclipse.jetty:jetty-jmx:9.2.1.v20140609")
    compile("org.eclipse.jetty.websocket:javax-websocket-server-impl:9.2.1.v20140609")
    compile("org.eclipse.jetty.spdy:spdy-http-server:9.2.1.v20140609")
    compile("org.eclipse.jetty:jetty-proxy:9.2.1.v20140609")
    compile("org.eclipse.jetty:jetty-jsp:9.2.1.v20140609")
}
task jarWithoutResources(type: Jar,dependsOn:compileJava) {
    manifest{
        attributes 'Main-Class':'Start'
    }
    from("$buildDir/classes/main")
    archiveName("start.jar")
}
2.新建一个含有main方法的可执行类(此类的编写主要参考jetty官方文档:http://www.eclipse.org/jetty/documentation/current/using-annotations-embedded.html).
Start.java:
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class Start {
    public static void main(String[] args) throws Exception {
        //Get parameters
        String resourceBase=PropertyUtil.getProperty("resourceBase");
        if (resourceBase==null) throw new Exception("resourceBase can not be null");
        String portTmp=PropertyUtil.getProperty("port");
        int port=portTmp==null?8080:Integer.valueOf(portTmp);
        String contextPath=PropertyUtil.getProperty("contextPath");
        contextPath=contextPath==null?"/":contextPath;
        String extraClasspath=PropertyUtil.getProperty("extraClasspath");
        extraClasspath=extraClasspath==null?"":extraClasspath;

        Server server = new Server(port);
        //Enable parsing of jndi-related parts of web.xml and jetty-env.xml
        org.eclipse.jetty.webapp.Configuration.ClassList classList = org.eclipse.jetty.webapp.Configuration.ClassList.setServerDefault(server);
        classList.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", "org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration");
        classList.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
        //Create a WebAppContext
        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath(contextPath);
        webapp.setResourceBase(resourceBase);
        webapp.setExtraClasspath(extraClasspath);
        server.setHandler(webapp);
        server.start();
        server.join();
    }
}
和上篇文章的war包配置的嵌入式jetty例子很相似,将setWar改成了setResourceBase和setExtraClasspath,另外上面利用PropertyUtil从.properties文件获取属性配置.
server.properties文件如下:
#默认为'8080'
port=8080
#默认为'/'
contextPath=/test
#必须指定
resourceBase=E:/idea/test/src/main/webapp
#默认为''
extraClasspath=E:/idea/test/build/classes/main/;E:/idea/test/build/resources/main/;E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-webmvc/3.2.8.RELEASE/b23357096216fee7fa658c3e0a28a4574d4d3a90/spring-webmvc-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework.data/spring-data-jpa/1.5.2.RELEASE/6e8608622fd11205238d8d1363f099c2a638a0bf/spring-data-jpa-1.5.2.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-orm/3.2.8.RELEASE/b1f3ef4edfd5344207ed03c361e17bbdf3251c49/spring-orm-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-tx/3.2.8.RELEASE/af44bdd6dd44557f6a03021a7d2721bbf1708ec1/spring-tx-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.hibernate/hibernate-entitymanager/4.3.1.Final/c27f33216ed0d0351f1ecf6a5b6f6c490b4bcbb9/hibernate-entitymanager-4.3.1.Final.jar; E:/gradlerepo/caches/modules-2/files-2.1/c3p0/c3p0/0.9.1.2/4ea71601f844c4b90d22195bbdb58979281bb8b6/c3p0-0.9.1.2.jar; E:/gradlerepo/caches/modules-2/files-2.1/mysql/mysql-connector-java/5.1.26/f1697bef3639811e56173e70eb2471562e3ac8ef/mysql-connector-java-5.1.26.jar; E:/gradlerepo/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.3.1/c4096a8323bbbcbeda072e3def123a9b66783361/jackson-databind-2.3.1.jar; E:/gradlerepo/caches/modules-2/files-2.1/commons-fileupload/commons-fileupload/1.3.1/c621b54583719ac0310404463d6d99db27e1052c/commons-fileupload-1.3.1.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.slf4j/slf4j-nop/1.7.6/3d219ee4ed4965348a630ff6ef2a5418032b9466/slf4j-nop-1.7.6.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.apache.taglibs/taglibs-standard-impl/1.2.1/707591cd2ac6cc1b6beff4c0439873e03fa3a6b0/taglibs-standard-impl-1.2.1.jar; E:/gradlerepo/caches/modules-2/files-2.1/javax.servlet/javax.servlet-api/3.1.0/3cd63d075497751784b2fa84be59432f4905bf7c/javax.servlet-api-3.1.0.jar; E:/gradlerepo/caches/modules-2/files-2.1/javax.servlet.jsp/jsp-api/2.2.1-b03/c7205b380e9ceb4b96745656755f31f76ae01b74/jsp-api-2.2.1-b03.jar; E:/gradlerepo/caches/modules-2/files-2.1/javax.servlet.jsp.jstl/javax.servlet.jsp.jstl-api/1.2.1/f072f63ab1689e885ac40c221df3e6bb3e64a84a/javax.servlet.jsp.jstl-api-1.2.1.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-beans/3.2.8.RELEASE/7aa7d1192ad7acc4b5ced07d44a1cdc4e3a377b9/spring-beans-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-context/3.2.8.RELEASE/7edfc6e4283b549504793682cab1f8c37d9f1890/spring-context-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-core/3.2.8.RELEASE/64b9b731decc74403eb85163278659d91c300584/spring-core-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-expression/3.2.8.RELEASE/becdd45da4986fb6d8936188f90dc869b6c237a1/spring-expression-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-web/3.2.8.RELEASE/799ae0503da5a9f980fecd38c9e6b23a71a406c8/spring-web-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework.data/spring-data-commons/1.7.2.RELEASE/ccaf8f785382bdef27a0c287d2d75af7e5c8dccf/spring-data-commons-1.7.2.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-aop/3.2.8.RELEASE/90e7924ef58621a4c07c81279e013d9a11d41789/spring-aop-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.aspectj/aspectjrt/1.7.4/e49a5c0acee8fd66225dc1d031692d132323417f/aspectjrt-1.7.4.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.6/562424e36df3d2327e8e9301a76027fca17d54ea/slf4j-api-1.7.6.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.slf4j/jcl-over-slf4j/1.7.6/ab1648fe1dd6f1e5c2ec6d12f394672bb8c1036a/jcl-over-slf4j-1.7.6.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.springframework/spring-jdbc/3.2.8.RELEASE/8fc09a51ca267726ffd284ab4de7c02f667da2ad/spring-jdbc-3.2.8.RELEASE.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.1.3.GA/64499e907f19e5e1b3fdc02f81440c1832fe3545/jboss-logging-3.1.3.GA.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging-annotations/1.2.0.Beta1/2f437f37bb265d9f8f1392823dbca12d2bec06d6/jboss-logging-annotations-1.2.0.Beta1.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.hibernate/hibernate-core/4.3.1.Final/73618cbf2dd1fa989a13d9444d4f025cfc51ec10/hibernate-core-4.3.1.Final.jar; E:/gradlerepo/caches/modules-2/files-2.1/dom4j/dom4j/1.6.1/5d3ccc056b6f056dbf0dddfdf43894b9065a8f94/dom4j-1.6.1.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.hibernate.common/hibernate-commons-annotations/4.0.4.Final/f1af75eca4e13ac0578750a497159695feceebfc/hibernate-commons-annotations-4.0.4.Final.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.hibernate.javax.persistence/hibernate-jpa-2.1-api/1.0.0.Final/5e731d961297e5a07290bfaf3db1fbc8bbbf405a/hibernate-jpa-2.1-api-1.0.0.Final.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.jboss.spec.javax.transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/1f9fef7a9fcbb41cc390fc370a291cf30729e094/jboss-transaction-api_1.2_spec-1.0.0.Final.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.javassist/javassist/3.18.1-GA/d9a09f7732226af26bf99f19e2cffe0ae219db5b/javassist-3.18.1-GA.jar; E:/gradlerepo/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.3.0/f5e853a20b60758922453d56f9ae1e64af5cb3da/jackson-annotations-2.3.0.jar; E:/gradlerepo/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.3.1/f9f7185c92ca5fefe2fb3efdeb477a67c96ea2d0/jackson-core-2.3.1.jar; E:/gradlerepo/caches/modules-2/files-2.1/commons-io/commons-io/2.2/83b5b8a7ba1c08f9e8c8ff2373724e33d3c1e22a/commons-io-2.2.jar; E:/gradlerepo/caches/modules-2/files-2.1/commons-logging/commons-logging/1.1.3/f6f66e966c70a83ffbdb6f17a0919eaf7c8aca7f/commons-logging-1.1.3.jar; E:/gradlerepo/caches/modules-2/files-2.1/aopalliance/aopalliance/1.0/235ba8b489512805ac13a8f9ea77a1ca5ebe3e8/aopalliance-1.0.jar; E:/gradlerepo/caches/modules-2/files-2.1/antlr/antlr/2.7.7/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar; E:/gradlerepo/caches/modules-2/files-2.1/org.jboss/jandex/1.1.0.Final/e84a2122e76f0b6503be78094ddf2108057ac15f/jandex-1.1.0.Final.jar; E:/gradlerepo/caches/modules-2/files-2.1/xml-apis/xml-apis/1.0.b2/3136ca936f64c9d68529f048c2618bd356bf85c9/xml-apis-1.0.b2.jar
port,contextPath,resourceBase的设置都是容易理解的.额外的类路径extraClasspath指的意思:当启动jetty的时候,类加载器也从这些位置加载类文件.jar文件或目录要以分号或逗号分隔,并且是目录时,要以'/'结尾.上面例子的意思当启动这个嵌入式jetty,应先加载E:/idea/test/build/classes/main/,E:/idea/test/build/resources/main/两个目录下的文件和项目依赖的一些jar包.
至于这些依赖jar包路径可通过以下任务获得
task('jarPath')<<{
    println configurations.runtime.asPath
}
3.运行一下main方法,就可以通过浏览器来访问这个web应用了.
如果开发每个应用都要打开这个工程,再运行调试,这样当然不方便.我希望通过一个命令能直接运行就可以启动这个jetty.那么继续进行下面第4步.
4.从第3步的运行,可以拷贝出这个运行命令,但这个命令相当长,我测试终端里dos命令最大输入长度是8190,而这个命令很可能超过限制,那么可以写一个start.bat文件来执行就可以了.下面是我拷贝再修改后的start.bat文件
D:\jdk7\bin\java -Didea.launcher.port=7535 -Didea.launcher.bin.path=D:\idea\bin -Dfile.encoding=UTF-8 -classpath .;E:\idea\webApp\build\classes\main;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-server\9.2.1.v20140609\d02c51c4f8eec3174b09b6e978feaaf05c3dc4ea\jetty-server-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\javax.servlet\javax.servlet-api\3.1.0\3cd63d075497751784b2fa84be59432f4905bf7c\javax.servlet-api-3.1.0.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-http\9.2.1.v20140609\a132617cb898afc9d4ce5d586e11ad90b9831fff\jetty-http-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-io\9.2.1.v20140609\8465fe92159632e9f0a1bfe6951dba8163ac0b12\jetty-io-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-util\9.2.1.v20140609\4ae7ac5d3cfcb21bc288dd3f4ec3ba2823442f0d\jetty-util-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-webapp\9.2.1.v20140609\906e0f4ba7a0cebb8af61513c8511981ba2ccf6e\jetty-webapp-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-xml\9.2.1.v20140609\d589789eb98d31160d11413b6323b9ea4569046\jetty-xml-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-servlet\9.2.1.v20140609\f2327faaf09a3f306babc209f9a7ae01b1528464\jetty-servlet-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-security\9.2.1.v20140609\8ac8cc9e5c66eb6022cbe80f4e22d4e42dc5e643\jetty-security-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-jsp\9.2.1.v20140609\3a2a54e3a64b5b592b1559439f8a1114f70ebbde\jetty-jsp-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.toolchain\jetty-schemas\3.1.M0\6179bafb6ed2eb029862356df6713078c7874f85\jetty-schemas-3.1.M0.jar;E:\gradlerepo\caches\modules-2\files-2.1\javax.servlet.jsp\javax.servlet.jsp-api\2.3.1\95c630902565feda8155eb32d46064ef348435fc\javax.servlet.jsp-api-2.3.1.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.glassfish.web\javax.servlet.jsp\2.3.2\613f624102267b1397e845b3181a72273bd6f399\javax.servlet.jsp-2.3.2.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.orbit\javax.servlet.jsp.jstl\1.2.0.v201105211821\db594f1c8fc00d536f6d135bd7f8a9a99a6b8eea\javax.servlet.jsp.jstl-1.2.0.v201105211821.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.glassfish.web\javax.servlet.jsp.jstl\1.2.2\5b2e83ef42b4eef0a7e41d43bb1d4b835f59ac7a\javax.servlet.jsp.jstl-1.2.2.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.orbit\org.eclipse.jdt.core\3.8.2.v20130121\ebb04771ae21dec8682e4153e97404d9933a9c13\org.eclipse.jdt.core-3.8.2.v20130121.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.glassfish\javax.el\3.0.1-b05\e2636f8692ca777408892ba24300ad8645543d84\javax.el-3.0.1-b05.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-annotations\9.2.1.v20140609\7e30f6278a6796ffc3dd3b868b666060863c0e8f\jetty-annotations-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-plus\9.2.1.v20140609\5fc8a98519613e0123d259e441debcf4d0bc69d\jetty-plus-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.2\479c1e06db31c432330183f5cae684163f186146\javax.annotation-api-1.2.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.ow2.asm\asm\5.0.1\2fd56467a018aafe6ec6a73ccba520be4a7e1565\asm-5.0.1.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.ow2.asm\asm-commons\5.0.1\7b7147a390a93a14d2edfdcf3f7b0e87a0939c3e\asm-commons-5.0.1.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-jndi\9.2.1.v20140609\215501a0b726d045ae5428cf2374d35ab1a3de02\jetty-jndi-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.ow2.asm\asm-tree\5.0.1\1b1e6e9d869acd704056d0a4223071a511c619e6\asm-tree-5.0.1.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-util-ajax\9.2.1.v20140609\5098579cf907c7380596a3f5a2cee4e2c23a998c\jetty-util-ajax-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-deploy\9.2.1.v20140609\51efbb61328b2da27a81707f423509947a824420\jetty-deploy-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-jmx\9.2.1.v20140609\1258d5ac618b120026da8a82283e6cb8ff4638a6\jetty-jmx-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.websocket\javax-websocket-server-impl\9.2.1.v20140609\71066d7fc33b41762996708fda5d732b13ea552d\javax-websocket-server-impl-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.websocket\websocket-server\9.2.1.v20140609\fae1005ec0ec309f7189a1975fa11263caaf9c2d\websocket-server-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.spdy\spdy-http-server\9.2.1.v20140609\eece1323526ac409af44e8db376f23c259ddcee7\spdy-http-server-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-proxy\9.2.1.v20140609\4466967fbfbdaf5edff4190218d4524e95c1bdb2\jetty-proxy-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.websocket\javax-websocket-client-impl\9.2.1.v20140609\654c8314ee706932bc3af8676ff71e8b9b4e9690\javax-websocket-client-impl-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\javax.websocket\javax.websocket-api\1.0\fc843b649d4a1dcb0497669d262befa3918c7ba8\javax.websocket-api-1.0.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.websocket\websocket-common\9.2.1.v20140609\b3548ae62923a25f258c56c2cc5a808c11c2b7fa\websocket-common-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.websocket\websocket-client\9.2.1.v20140609\c18c9e0585050a95953eeae597c5896cc015bb57\websocket-client-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.websocket\websocket-servlet\9.2.1.v20140609\712dcb55ff0fe9f888dd4bab8c9ce9557dc574d\websocket-servlet-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.spdy\spdy-http-common\9.2.1.v20140609\997215719bf1eabb6d2cd38a5ce4ab0cb4792ba1\spdy-http-common-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.spdy\spdy-server\9.2.1.v20140609\252ad4e8362f5cb6db6321b6eace5df3c6a64aeb\spdy-server-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-client\9.2.1.v20140609\b44739245fb8f2e1347ca2d56758f8c89a7508d6\jetty-client-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.websocket\websocket-api\9.2.1.v20140609\fa9821da09a02be69a341c72eb3fdd8b0f16e81c\websocket-api-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.spdy\spdy-core\9.2.1.v20140609\5e5e1bc965e8c8523f38ca8fde0e70a2f2f5f98d\spdy-core-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty.spdy\spdy-client\9.2.1.v20140609\afeeac261ccb29e52cf9e3409d3681414852fa71\spdy-client-9.2.1.v20140609.jar;E:\gradlerepo\caches\modules-2\files-2.1\org.eclipse.jetty\jetty-alpn-client\9.2.1.v20140609\63155fcb7a63f8186a873e1d830e4013f0e6327d\jetty-alpn-client-9.2.1.v20140609.jar;D:\idea\lib\idea_rt.jar com.intellij.rt.execution.application.AppMain Start
5.把server.properties和start.bat拷贝到test应用的根目录下.双击start.bat就可以启动jetty了.关闭这个窗口就可以关闭jetty.当然也可以打开IDEA的terminal来运行,ctrl+c就可以退出命令关闭jetty.有了这个server.property,就可以随时嵌入到一个web项目来启动jetty


另外:http://www.jetbrains.com/idea/documentation/migration_faq.html
问题提到Q: What happened to incremental compilation? How do I compile my project?答案的解析里有说得编译的时机.在IDEA里你按ctrl+s,并不会即时编译,可以按ctrl+shift+f9编译当前文件.而ctrl+f9可以编译整个项目.

小结:这基本可以前面所说的需求,修改类,自动reload功能没实现,感觉还是不太实用.做成gradle插件,就更好了!但不想花太多心思.


你可能感兴趣的:(spring,mvc,gradle,嵌入式,jetty,Web应用)