maven[tomcat/jetty]

Eclipse:

Base directory:${workspace_loc:project-name}
Goals:clean compile install -Dmaven.test.skip=true
Profiles:dev[对应pom.xml中的profile的ID]
User settings:自己选择
------------------------------------------------------------------------------
使用tomcat插件启动Web项目:
<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <port>8080</port>
        <path>/spider</path>
        <uriEncoding>UTF-8</uriEncoding>
        <finalName>spider</finalName>
        <server>tomcat7</server>
    </configuration>
</plugin>

mvn tomcat7:run
additional: no need to configure the plug-in, use the following is the default tomcat6 version
tomcat:run -Dmaven.tomcat.uriEncoding=UTF-8 -Dmaven.tomcat.path=/ -Dmaven.tomcat.port =8088
------------------------------------------------ -------------------------------

Start the web project using the jetty plugin: jetty:run -Djetty.port=8088
Add the project source code : Source Tab Add   Java Project


Check $M2_HOME environment variable and mvn script match
solution: Maven=”Runner=>VM Options, fill
in -Dmaven.multiModuleProjectDirectory=$M2_HOME

jetty plugin:
cancel file mapping cache
    jetty has useFileMappedBuffer enabled by default, in jetty During runtime, static files (such as css files, etc.) used by the page are not allowed to be modified. If you try to modify them, Save could not be completed will appear when saving.
    The solution, find %repo%/org/eclipse/jetty/jetty-webapp/9.2.8.v20150217/jetty-webapp-9.2.8.v20150217.jar, open it with a compression tool, find jetty-webapp-9.2.8 .v2015021
7.jar/org/eclipse/jetty/webapp/webdefault.xml, unzip a copy of the webdefault.xml file, open it with a text editor, search to find the line of useFileMappedBuffer configuration, change true to false to disable Drop cache. Delete the original file org/eclipse/jetty/webapp/webdefault.xml and recompress the modified webdefault.xml file.
    Of course, we can copy a copy and put it in the project source code, and overwrite the jar package by configuring the specified webdefault.xml in the plugin. For details, see the plugin configuration item:

<build>
  <plugins>
    <plugin>
      <groupId> org.eclipse.jetty</groupId>
      <artifactId>jetty-maven-plugin</artifactId>
      <version>9.2.8.v20150217</version>
      <configuration>
        <!-- Unmap the specified file from the cache -->
        <webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
        <webAppSourceDirectory>src/main/webapp</webAppSourceDirectory>
        <!--
           corresponding to -Djetty.scanIntervalSeconds=2 startup item, which means hot deployment, default 0 means close , the unit is seconds;
           with the configured value as a cycle, the file is automatically scanned to check whether the content has changed. If the content of the file is found to be changed, the application will be automatically redeployed.
        <scanIntervalSeconds>3</scanIntervalSeconds>
        -->
        <contextPath>/</contextPath>
        <connectors>
          <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
            <port>8888</port>
          </connector>
        </connectors>
      <


</build>



mvn archetype:create -DgroupId=com.yy -DartifactId=sm -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326428719&siteId=291194637
Recommended