Setup Eclipse and Tomcat to play nice together
2011-08-23 10:59
441 查看
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 hot
deploy 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 restart
almost 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’s
WEB-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/
deploy 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 restart
almost 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’s
WEB-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/
相关文章推荐
- Setup Eclipse and Tomcat to play nice together
- on Ubuntu 12.04 to install and setup the tomcat 7
- How to Install Eclipse ADT, Android SDK, and setup AVD Emulator
- eclipse server locations disabled and need to change to use tomcat installation
- Open debug mode for Tomcat and use Eclipse to remote debug the application
- MSMQ, WCF and IIS: Getting them to play nice (Part 1)[转]
- How to setup Eclipse with WinAVR and the Eclipse plugin AVR-eclipse
- MSMQ, WCF and IIS: Getting them to play nice (Part 2)[转]
- MSMQ, WCF and IIS: Getting them to play nice (Part 3)[转]
- Making ARC and non-ARC files play nice together
- Setup Eclipse to Compile and Run OIM Custom Clients
- Eclipse Tomcat 8 警告: Unable to add the resource at [***] to the cache...
- To be Open and Nice
- How to setup tomcat in linux?
- How to setup java remote debugging in eclipse
- [置顶] Android无法启动AVD解决方法出现"The connection to adb is down...You must restart adb and Eclipse."
- The connection to adb is down, and a severe error has occured. You must restart adb and Eclipse.
- eclipse:关于The connection to adb is down, and a severe error has occured.
- Using VisualVM to fix live Tomcat and JVM problems
- Eclipse(Java EE) 报错:Server Tomcat v7.0 Server at localhost failed to start.