如何在 IDEA 中使用Maven 及 相应插件

1,Maven 面板 html

image

 

 

Root ,至关于 VS 中的 sln ? ,大概能够这样理解吧。java

 

clean  --> install  这样操做, 全部的项目都会被执行。 web

手工操做有点麻烦。换另外一种方式 apache

在控制台执行tomcat

 

image

 

 

mvn clean install -Dmaven.test.skip=true –X  
与上面的命令类似的

    mvn install  -Dmaven.test.skip=true -Djar.forceCreation  -X  (试用后感受这条比clean 好些, clean 会删除文件,若是正在热部署,会产生文件锁定的可能性没法删除,这条暂时还没遇到)
eclipse

 
其它的命令还有
mvn clean compile、mvn clean test、mvn clean package、mvn clean install
 
 
2,启动WEB容器
 
通常状况下,推荐使用 集成容器, 为何呢?在 VS开发中,如今谁不用IIS Express 去运行,调试代码呢?
 
image
 
jetty和tomcat 均可以,通常 我用 jetty , 你们都说jetty快, 我也没以为,心理做用吧。不过, java web 容器的启动真是无语。慢或者出错就启不来了
另外,我已经将 这两个插件配置成为热部署, (也就是 容器检测到内容的改变,会自动重启加载)
 
下面是Pom中与之相应的配置节点
 
<build>    <plugins>        <!--tomcat7插件-->        <!--https://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/run-mojo.html-->        <plugin>            <groupId>org.apache.tomcat.maven</groupId>            <artifactId>tomcat7-maven-plugin</artifactId>            <version>${tomcat7-maven-plugin.version}</version>            <configuration>                <path>${tomcat-path.version}</path>                <port>${tomcat-port.version}</port>                <uriEncoding>${tomcat-uri-encoding.version}</uriEncoding>                <url>http://localhost:8080/manager/text</url>                <server>tomcat7</server>                <username>admin</username>                <password>admin</password>                <contextReloadable>true</contextReloadable>                <update>true</update>            </configuration>        </plugin>        <!--jetty插件-->        <!--http://www.eclipse.org/jetty/documentation/9.0.0.M3/jetty-maven-plugin.html-->        <plugin>            <groupId>org.mortbay.jetty</groupId>            <artifactId>jetty-maven-plugin</artifactId>            <version>${jetty-plugin.version}</version>            <configuration>                <stopKey>foo</stopKey>                <stopPort>8081</stopPort>                <connectors>                    <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">                        <port>${jetty-port.version}</port>                    </connector>                </connectors>                <webApp>                    <contextPath>${jetty-path.version}</contextPath>                </webApp>                <!--scanIntervalSeconds 可选[秒]。在很短的时间间隔内在扫描web应用检查是否有改变,若是发觉有任何改变则自动热部署。默认为0,表示禁用热部署检查。任何一个大于0的数字都将表示启用。-->                <scanIntervalSeconds>1</scanIntervalSeconds>            </configuration>        </plugin>    </plugins></build>
相关文章
相关标签/搜索