Differences between myeclipse and eclipse web project deployment, myeclipseeclipse
1. myeclipse web project deployment (release) process 2008-01-18
Create a web project abc under myeclipse. The default settings are as follows:
Project SAVE location: workspace directory \ abc
Source folder: src, which stores all Java class files (. java files) and xml files.
Web root folder: WebRoot, which stores all jsp files, including css and JavaScript. Contains the WEB-INF folder has a very important role!
Context root URL:/abc. /Indicates the upper layer, And/abc points to the local directory.
The project folder contains a total of 6 files and folders:
. Myeclipse folder
Src folder
WebRoot folder
Files at the same level:
. Classpath File
. Mymetadata File
. Project File
Deploy a project in myeclipse
Take the project name abc as an example. The release location is the abc directory under the webapps directory under the Tomcat installation directory by default.
Generally, the Tomcat \ webapps \ abc directory completely copies all content in myeclipse \ workspace \ abc \ WebRoot.
The deployment process is to copy the content in myeclipse WebRoot to Tomcat's Webapps \ abc and restart Tomcat.
The WebRoot directory contains index. jsp.
When you access the web, enter http: // localhost: 8080/abc to point to index. jsp In the Tomcat \ webapps \ abc directory.
Normal access!
Composition of WebRoot:
WebRoot \ WEB-INF \ classes directory is very interesting!
Workspace \ abc \ WebRoot \ WEB-INF \ classes directory and workspace \ abc \ src directory one-to-one correspondence! All the compiled. class files are stored here. The deployment only exposes bytecode, And the java class files are still stored on the development platform.
The src directory contains java class files (. java)
The classes directory contains the bytecode file (. class)
C: \ AAAA \ I _sales \ src and C: \ AAAA \ I _sales \ WebRoot \ WEB-INF \ classes
The structure and file name are identical. Only change all extensions. java to. class.
Summary:
1. the WebRoot folder is an external product! Copy it to Tomcat.
2. the src directory contains heavyweight java programs. After compilation, they will be placed into WebRoot.
3. jsp pages, javascript, and css are directly written in WebRoot. Organize the directory structure on your own to facilitate classification management.
2. Deployment of eclipse web Project
... Tomcat \ conf \ Catalina \ localhost \ tracker. xml <Context path = "/tracker" reloadable = "true" docBase = "D: \ web \ tracker" workDir = "D: \ web \ tracker \ work "/> in... create the project path file tracker in the \ localhost directory. xml, Which is null as above .. the value "/tracker" in path and the file name tracker. xml must be consistent .. docBase is the root directory of your page file .. workDir is the address where java files are stored after jsp files are compiled into java files.
Iii. Eclipse + Tomcat + Ant
1. Open Eclipse and create the builds. xml file under the root path of the project.
This is the key to Ant configuration. The content is as follows:
-----------------
<? Xml version = "1.0"?>
<Project name = "webmodulebuilder" default = "deploy" basedir = ".">
<! -- Set global properties for this build -->
<! -- Publish the WEB path -->
<Property name = "DEPLOY_PATH" value = "D:/Tomcat 5.0/webapps/dt"/>
<! -- Source WEB path -->
<Property name = "WEB_PATH" value = "D:/eclipse/workspace/test/dt"/>
<! -- Path of the jar package compiled by the source -->
<Property name = "JAR_PATH" value = "D:/eclipse/workspace/test/dt/WEB-INF/lib"/>
<! -- Source java file path -->
<Property name = "SCR_PATH" value = "D:/eclipse/workspace/test/src"/>
<! -- Source class file path -->
<Property name = "CLASS_PATH" value = "D:/eclipse/workspace/test/dt/WEB-INF/classes"/>
<! -- Define classpath -->
<Path id = "LIB_CLASS_PATH">
<Fileset file = "$ {JAR_PATH}/*. jar"/>
<Pathelement path = "$ {CLASS_PATH}"/>
</Path>
<! -- Preliminary Test -->
<Target name = "init">
<Mkdir dir = "$ {DEPLOY_PATH}"/>
<Mkdir dir = "$ {DEPLOY_PATH}/WEB-INF"/>
<Mkdir dir = "$ {DEPLOY_PATH}/WEB-INF/classes"/>
<Mkdir dir = "$ {DEPLOY_PATH}/WEB-INF/lib"/>
</Target>
<! -- Compile class -->
<Target name = "compile" depends = "init" description = "compile the source files">
<Mkdir dir = "$ {CLASS_PATH}"/>
<Javac srcdir = "$ {SCR_PATH}" destdir = "$ {CLASS_PATH}">
<Classpath refid = "LIB_CLASS_PATH"/>
</Javac>
</Target>
<! -- Copy publish -->
<Target name = "deploy" depends = "init, compile">
<Copy todir = "$ {DEPLOY_PATH}">
<Fileset dir = "$ {WEB_PATH}">
<Include name = "**/*. *"/>
<Exclude name = "**/jsp_servlet/*. class"/>
<Exclude name = "**/build. xml"/>
<Exclude name = "**/deploy. xml"/>
<Exclude name = "**/build. properties"/>
<Exclude name = "**/servers. xml"/>
<Exclude name = "**/targets. xml"/>
<Exclude name = "**/*. war"/>
</Fileset>
</Copy>
</Target>
</Project>
-----------------
2. Right-click the project and select "properties -- builder ". Click "new ".
3. In the select Configuration type window, click Select Ant build and click OK ".
4. Configure the properties of the builder and enter the builder's "name ".
In the "Main" Page, select "Build File", select builds. xml Just configured, and "Basic directory" select the project root directory.
In "build options", select "during Automatic Build ".
5. Click "OK" to complete the configuration.
6. Select the Ant builder you just created in the builder in the Project Properties and deselect the Java builder check box ". Click OK ".
7. During system debugging, Ant will automatically compile and release the file to the specified directory. Great!