原来公司一直使用eclipse,突然使用这个intellij还真有点不习惯,等用了一段时间才发现的确好用,因为也是刚开始用,所以很多不理解的地方,搭建一个项目从头好好了解下intellij

最开始的maven搭建web 参考的http://blog.csdn.net/zht666/article/details/8673609 不过我这里没有使用tomcat,而是用的jetty插件,因为用独立tomcat时,freemarker修改模板无法实时同步

在pom文件里加入

<build>
        <plugins>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <scanIntervalSeconds>1</scanIntervalSeconds>
                    <stopPort>9966</stopPort>
                    <stopKey>foo</stopKey>
                    <connectors>
                        <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                            <port>7777</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                    <webAppSourceDirectory>
                        ${basedir}/webapp
                    </webAppSourceDirectory>
                    <webAppConfig>
                        <contextPath>/spring</contextPath>
                    </webAppConfig>
                </configuration>
            </plugin>
        </plugins>
    </build>

 有2个地方注意下,contextPath可能比较好理解,就是当jetty启动成功后,访问地址时加上的路径

<webAppSourceDirectory> 这个是配置通过访问路径找到项目中对应的jsp文件的,如果不指定就会到${basedir}/src/main/下去找webapp文件夹

这个是配置好的jetty插件

目录

 启动成功的信息
[INFO] --- jetty-maven-plugin:8.1.14.v20131031:run (default-cli) @ SpringMvc ---
[INFO] Configuring Jetty for project: SpringMvc
[INFO] Webapp source directory = D:\temp\SpringMvc\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = D:\temp\SpringMvc\target\classes
[INFO] Context path = /spring
[INFO] Tmp directory = D:\temp\SpringMvc\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = file:/D:/temp/SpringMvc/webapp/WEB-INF/web.xml
[INFO] Webapp directory = D:\temp\SpringMvc\webapp

访问下看看

这个就算是基本调好了,不过现在谁还用jsp,都是freemarker了,所以把freemarker和spring加上吧
posted on 2014-02-08 16:40  程序猿_哲  阅读(1053)  评论(1编辑  收藏  举报