Eclipse on-click deploy to remote Tomcat

后端 未结 1 1939
执笔经年
执笔经年 2020-12-02 19:09

I\'ve been looking for this all-over the internet and somehow I can\'t find a easy way to do it.

What I need is really simple and I believe that many of you probabl

相关标签:
1条回答
  • 2020-12-02 19:48

    Yes, you can use Tomcat7 Maven Plugin. Here is the steps:

    1) Install Maven Integration for Eclipse (m2eclipse) to your eclipse from Eclipse Marketplace etc.

    1.1) Navigate to Help -> Eclipse Marketplace and search "Maven Integration for Eclipse".

    2) From eclipse, create a maven project.

    2.1) Navigate to File -> New -> Project... -> Maven -> Maven Project.

    2.2) Click Next (Leave all fields with default).

    2.3) Select "maven-archetype-webapp" and click Next.

    2.4) Enter arbitrary value on Group Id and Artifact Id. (e.g. "org.myorg" for Groupd Id and "myapp" for Artifact Id) and click Finish. (You will see pom.xml in your project's root.)

    3) Edit pom.xml like this: (Replace yourhost below with your hostname or ip address.)

    <project ...>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>
            <configuration>
              <url>http://yourhost:8080/manager/text</url>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </project>
    

    4) Add following lines to your CATALINA_BASE/conf/tomcat-users.xml and restart your tomcat.

    <tomcat-users>
      ...
      <role rolename="manager-script"/>
      <user username="admin" password="" roles="manager-script"/>
    </tomcat-users>
    

    5) From eclipse, run tomcat7:redeploy goal.

    5.1) Right click your project and navigate to Run As -> "Maven build...".

    5.2) Enter tomcat7:redeploy to Goals and click Run.

    6) Once you create the run configuration setting above, you can run tomcat7:redeploy goal from Run -> Run Configurations.

    Please refer to the following documents for details:

    http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Configuring_Manager_Application_Access

    http://tomcat.apache.org/maven-plugin-2.1/index.html

    http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/plugin-info.html

    If you use another user instead of admin with empty password (which is plug-in's default), you need to create %USERPROFILE%.m2\settings.xml and edit pom.xml like below:

    %USERPROFILE%.m2\settings.xml:

    <settings>
      <servers>
        <server>
          <id>tomcat7</id>
          <username>tomcat</username>
          <password>tomcat</password>
        </server>
      </servers>
    </settings>
    

    %USERPROFILE% is your home folder. (e.g. C:\Users\yourusername)

    pom.xml:

    <configuration>
      <server>tomcat7</server>
      <url>http://localhost:8080/manager/text</url>
    </configuration>
    

    Add server tag.

    0 讨论(0)
提交回复
热议问题