Implementation steps:
1. Download the Eclipse Tomcat Plugin (abbreviated)
2. Configure Tomcat
Tomcat configuration entry found in Window-->preperences after the Tomcat plugin download is complete
?
3. Configure Server.xml
Locate the Server.xml file in the conf/directory and add the following to the Engine tab:
4. Configure the Hosts file
Locate the Hosts file under the Windows/system32/drivers/etc directory and add the following:
#127.0.0.1 localhost#::1 localhost127.0.0.1 www2.domain1.com www2.domain2.com Www2.domain3.com
5. Build the JAR Package
1. Create a new project (or use the original project), creating a package with the name: Org.apache.catalina.loader, then create a class with the name Mydevloader, copy the following Java code section
Note: You can create a package name and class name at will, but need to <loader classname= "Org.apache.catalina.loader.MyDevLoader" reloadable= "true" debug= "1" Usesystemclassloaderasparent= "false"/> in the classname to remain one to be able.
2, eliminate the compilation error place. The associated jar packages are not introduced in the Lib directory, which is primarily in Tomcat.
3, re-dozen into a jar package, named Devloadertomcat8.jar.
4. Place the jar file into the Lib directory in Tomcat.
PackageOrg.apache.catalina.loader;importJava.io.file;importJava.io.filefilter;importJava.io.filereader;importJava.io.ioexception;importJava.io.linenumberreader;importJava.net.malformedurlexception;importJava.net.url;importJava.util.arraylist;importJava.util.iterator;importJava.util.list;importJava.util.stringtokenizer;importJavax.servlet.servletcontext;importOrg.apache.catalina.context;importOrg.apache.catalina.globals;importorg.apache.catalina.lifecycleexception;/** * @author Caoxiaobo * Note: After modifying the DevLoader source, generate the jar package and place the Lib directory in Tomcat; */ public class Mydevloader extendsWebapploader {private static final String info = "org.apache.catalina.loader.mydevloader/1.0"; Private String Webclasspathfile = ". #webclasspath"; Private String Tomcatpluginfile = ". Tomcatplugin"; PublicMydevloader () {Super(); } publicMydevloader (ClassLoader parent) {Super(parent); }/** * @see Org.apache.catalina.lifecycle#start () * If you are using TOMCAT7, the method name here is start (), and if it is Tomcat8, the method name here is Startinternal () */public void startinternal () throwslifecycleexception {log ("starting Mydevloader")); Setloaderclass (DevWebappClassLoader.class.getName ()); If it is TOMCAT7, call the Start () method here, and if it is tomcat8, call the Startinternal () method here//Super.start (); TOMCAT7 super.startinternal (); Tomcat8ClassLoader cl = Super. getClassLoader (); if (cl instanceof WebappClassLoader = = False{LogError ("Unable to install WebappClassLoader!")); Return; } WebappClassLoader DEVCL =(WebappClassLoader) CL; List webclasspathentries =Readwebclasspathentries (); StringBuffer classpath = newStringBuffer (); for (Iterator it =Webclasspathentries.iterator (); It.hasnext ();) {String Entry =(String) It.next (); File f = newFile (entry); If(F.exists ()) {if (f.isdirectory () && entry.endswith ("/") ==false) F = new File (entry + "/"); Try{URL url =F.tourl (); Devcl.addurl (URL); tomcat8//devcl.addrepository (url.tostring ()); TOMCAT7 Classpath.append (f.tostring () +File.pathseparatorchar); Log ("added" +Url.tostring ()); } catch(Malformedurlexception e) {LogError (entry + "Invalid (Malformedurl)"); }} else{LogError (entry + "does not exist!")); }}/* try {devcl.loadclass ("at.kase.webfaces.WebApplication"); Devcl.loadclass ("At.kase.taglib.BaseTag"); Devcl.loadclass ("At.kase.taglib.xhtml.XHTMLTag"); Devcl.loadclass ("At.kase.common.reflect.ClassHelper"); Devcl.loadclass ("Javax.servlet.jsp.jstl.core.Config"); Log ("All OKAY!"); } catch (Exception e) {logError (e.tostring ());} */String CP =(String) Getservletcontext (). getattribute (globals.class_path_attr); StringTokenizer tokenizer = new StringTokenizer (CP, file.pathseparatorchar+ ""); While(Tokenizer.hasmoretokens ()) {String token =Tokenizer.nexttoken (); Only on Windows if (Token.charat (0) = = '/' && token.charat (2) = = ': ') token = token.substring (1); Classpath.append (token +File.pathseparatorchar); }//CP = Classpath + cp;Getservletcontext (). SetAttribute (Globals.class_path_attr, classpath.tostring ()); Log ("Jspcompiler Classpath =" +CLASSPATH); } protected voidLog (String msg) {System.out.println ("[Mydevloader]" +msg); } protected voidLogError (String msg) {System.err.println ("[Mydevloader] Error:" +msg); } protectedList readwebclasspathentries () {list rc = null; File Prjdir =Getprojectrootdir (); if (Prjdir = = NULL) {return newArrayList (); } log ("projectdir=" +Prjdir.getabsolutepath ()); Try loading Tomcat plugin file//DON "T LOAD Tomcat plugin file (doesn ' t has full PATHS anymore)//RC = Loadtomcatplug InFile (Prjdir); if (RC ==null) {rc =Loadwebclasspathfile (Prjdir); } if (rc = = null) rc = new ArrayList (); Should not happen! ReturnRc } protectedFile Getprojectrootdir () {File RootDir =Getwebappdir (); FileFilter filter = newFileFilter () {public booleanAccept (file file) {return (File.getname (). Equalsignorecase (webclasspathfile) | |File.getname (). Equalsignorecase (Tomcatpluginfile)); } }; while (RootDir! = null) {file[] files =Rootdir.listfiles (filter); if (Files! = null && files.length >= 1) {return files[0].getparentfile (); } RootDir =Rootdir.getparentfile (); } return NULL; } protectedList loadwebclasspathfile (file prjdir) {File Cpfile = newFile (Prjdir, webclasspathfile); If(Cpfile.exists ()) {FileReader reader = null; Try{List rc = newArrayList (); reader = newFileReader (Cpfile); LineNumberReader lr = newLineNumberReader (reader); String line = null; while (line = Lr.readline ())! = NULL) {//convert ' \ ' to '/' line = line.replace (' \ \ ', '/')); Rc.add (line); } returnRc } catch(IOException Ioex) {if (reader! = null) try {reader.close ();} catch(Exception ignored) {} return Null; }} else{return null; }/* Protected List loadtomcatpluginfile (file prjdir) {file Cpfile = new File (Prjdir, tomcatpluginfile); if (Cpfile.exi STS ()) {FileReader reader = null; try {stringbuffer buf = new StringBuffer (); BufferedReader in = new BufferedReader (new InputStreamReader (New FileInputStream (Cpfile))); String Inputline; while ((Inputline = In.readline ()) = null) {buf.append (inputline); buf.append (' \ n ');} Webclasspathentries entries = Webclasspathentries.xmlunmarshal (buf.tostring ()); if (entries = = null) {log ("No entries found in Tomcatplugin file!"); return null;} return entries.getlist (); } catch (IOException Ioex) {if (reader! = null) try {reader.close ();} catch (Exception ignored) {} return null;}} else {return null;}} */ProtectedServletContext Getservletcontext () {//Return (Context) GetContainer ()). Getservletcontext ();//TOMCAT7 return Super.getcontext (). Getservletcontext (); Tomcat8 } protected file Getwebappdir () {File Webappdir = new File (Getservletcontext (). Getrealpath ("/")); return Webappdir;}}
Right-click Projects---Properties--Tomcat
At this point we have configured the end!
Click to start the project as marked
The following information appears to indicate a successful configuration.
Let Eclipse's tomcatplugin support Tomcat 8.x