Eclipse点击部署到远程Tomcat [英] Eclipse on-click deploy to remote Tomcat

查看:107
本文介绍了Eclipse点击部署到远程Tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找这个全面的互联网,不知何故,我找不到一个简单的方法来做到这一点。



我需要的是非常简单的,我相信你们中许多人可能已经做到了:
- 我在Eclipse中开发Java Web Apps,我的团队也是如此;
- 我们有一台运行在Ubuntu机器上的tomcat7服务器,它作为一个集中的开发环境;
- 我想单击一个部署按钮,并将新数据发送到服务器并部署(重新加载它),而不是每次导出战争,并手动将其上传到服务器。



到目前为止,似乎唯一的办法是使用Maven插件的eclipse,它使用tomcat的管理器/ HTML界面。



问题:我不能让它上班。但不知何故,我找不到一个简单的步骤,解释如何做到这一点。我不太熟悉eclipse或Linux,但本地tomcat服务器的配置看起来很简单。我不明白为什么这么难安装一个远程的。



请问你可以帮忙解释一下如何做吗?感谢您的耐心。

解决方案

是的,您可以使用Tomcat7 Maven Plugin。以下是以下步骤:



1)从Eclipse Marketplace等安装Eclipse的Maven Integration(m2eclipse)到eclipse。



1.1)导航到帮助 - > Eclipse Marketplace并搜索Maven Integration for Eclipse。



2)从eclipse创建一个maven项目。

2.1)导航到文件 - >新建 - >项目... - > Maven - > Maven项目。



2.2)单击下一步(默认为所有字段)。



2.3)选择maven-archetype-webapp,然后单击下一步。



2.4)在Group Id和Artifact Id上输入任意值。 (例如,Groupd Id为org.myorg,Artifact Id为myapp),然后单击完成。 (您将在项目的根目录中看到pom.xml。)



3)编辑pom.xml:(替换 yourhost 以下,您的主机名或IP地址。)

 < 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)将以下行添加到CATALINA_BASE / conf / tomcat-users.xml中,然后重新启动tomcat。

 < tomcat-users> 
...
< role rolename =manager-script/>
< user username =adminpassword =roles =manager-script/>
< / tomcat-users>

5)从eclipse,运行tomcat7:重新部署目标。



5.1)右键单击您的项目并导航到运行方式 - >Maven构建...。



5.2)输入 tomcat7:重新部署到目标,然后单击运行。



6)创建上述运行配置设置后,可以运行tomcat7:重新部署目标运行 - >运行配置。



有关详细信息,请参阅以下文档:



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-plugi n / plugin-info.html



如果您使用其他用户而不是管理员使用空密码(这是插件的默认值),则需要创建%USERPROFILE%.m2\settings.xml并编辑pom.xml,如下所示:



%USERPROFILE%.m2\settings.xml:

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

%USERPROFILE%是您的主文件夹。 (例如C:\Users\yourusername)



pom.xml:

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

添加服务器标签


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 probably do it already: - I develop Java Web Apps in Eclipse and so does my team; - we have a tomcat7 server running on a Ubuntu machine which works as a centralized Dev environment; - I would like to click a deploy button and send the new data to the server and deploy it (reload it), instead of exporting a war every time and manually upload it to server.

Up till now seems like the only way to do it is with Maven plugin for eclipse, which uses the manager/HTML interface of tomcat.

Problem: I just can't get it to work. But somehow I can't find a simple walk through that explains how to do it. I'm not too experienced with eclipse or Linux but the configuration of local tomcat servers seems pretty straightforward. I don't understand why is so hard to install a remote one.

Could you please help me out by explaining in detail how to do it? Thank you in advance for you patience.

解决方案

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.

这篇关于Eclipse点击部署到远程Tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆