设为首页 收藏本站
查看: 410|回复: 0

[经验分享] Setup Eclipse and Tomcat to play nice together

[复制链接]

尚未签到

发表于 2017-2-3 08:04:28 | 显示全部楼层 |阅读模式
  Eclipse is by far my favorite IDE, which makes Rational Application Developer bearable. The one thing I’ve been spoiled on in RAD is being able to run the WebSphere Test Environment inside the development environment and be able to have some level of hotdeploy when modifying classes or jsp’s in the web project. This brings me to my problem with Eclipse and Tomcat, Eclipse provides great support for adding a Tomcat server to run in your IDE, but the default classpath set up forces you to do a build and restartalmost everytime you modify a JSP or Class, this is a real pain. The other pain is that by default when you set up a web project, eclipse decides to build your src files into a build directory rather than just building them directly into the web project’sWEB-INF/classes directory.
  This is what I’m here to solve. I’m assuming your using Eclipse 3.2 (Callisto) with the Web Tools installed, JDK 1.5 or 1.6, and Tomcat 5.5 or 6. May work in earlier versions, but I haven’t set up any projects like that recently.

Create a new Dynamic Web Project

  • Open Eclipse
  • Create a New Web Project
  • Open the Java Perspective
  • Right click and choose New -> Project
  • Under Web Folder Choose Dynamic Web Project Click Next, Click Next
  • Under Project Facets choose Dynamic Web Module, Java, Click Next
  • Change Context Root to / Click Finish
  Change the Build Path

  • Right click the Project and choose Properties
  • Choose Java Build Path in the Left Panel, Click the Source Tab
  • Change the Default output folder to: yourprojectname/WebContent/WEB-INF/classes
  • Click OK
  Create Tomcat Server

  • Right click and choose New -> Other
  • Under Server Folder Choose Server Click Next
  • Under Apache Choose Tomcat v5.5 Server Click Next
  • Under Tomcat installation directory: Browse to the place where you unzipped the Tomcat installation
  • Under JRE: Make sure jre1.5.x is selected, you may need to add the jre if a different one is installed on your computer. Click Next
  • Choose the project you created from Available projects to Configured projects Click Finish
  • Open the Server View, if it’s not displayed already – Window –> Show View–> Other–> Choose Servers under Server
  • Save the Perspective so that the Servers View will also be displayed
  • The server you just created will appear in the Servers View
  • Right Click the server and choose Move to Workspace
  • Double click the Server and the Server Overview will be opened.
  • Change the Server Name to something meaningful like YourProjectName Server, Save the configuration
  • Close the editor and it will ask you if you want to rename the diretory to match the server name, click yes
  • Open the server.xml
  • Change the appBase attribute of the Host node to contain the absolute path to your workspace directory ex. <Host appBase=”d:\web” autoDeploy=”true” name=”localhost” unpackWARs=”false” xmlNamespaceAware=”false” xmlValidation=”false”>
  • Change the port attribute of the Connector node to 80 and the redirectPort attribute to 443
  • Change the docBase attribute of the Context Node to contain the absolute path to your WebContent folder ex. <Context docBase=”d:\web\yourprojectname\WebContent” path=”/” reloadable=”true” source=”org.eclipse.jst.j2ee.server:forensicsalvage”/>
  You should be able to start the server up from the Server View and view you application and make live changes to your jsp’s, which should only require a refresh now.

  

  http://greatwebguy.com/programming/eclipse/make-eclipse-and-tomcat-play-nice-together/


http://peter9.iteye.com/blog/http://peter9.iteye.com/blog/http://peter9.iteye.com/blog/

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-336748-1-1.html 上篇帖子: Tomcat下没有JDK 安装版 的程序运行 下篇帖子: 关于Tomcat发布web项目时候不能发布的问题
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表