Flexible build web applications in Eclipse

xiaoxiao2021-03-06  36

Foreword

Ant is an important part of the Java Developer Toolbox, JUnit, XDoclet, etc., is closely related to it. The programmer may get used to the automatic build, even deployment features provided by IDE, which ignores Ant itself, in fact, the mainstream IDE usually It is a built-in Ant task to complete these work, familiar with Ant's internal mechanism, you can read or simply modify building.xml can help you integrate, manage application projects, if you need to learn Maven open source project management solutions, too To understand the Ant-based 哟. In addition, the process of using ANT actually documents the construction, it is no IDE, imagined, your colleague may be in one-third of JBuilderx, one-third with Eclipse, and some of.

I use Eclipse3.0.1, the previous construction and posting work is made by myECLIPSE plugin, and the weekend practices manual build. Remember this memission.

practice

Preparation: This is my personal habit, put all the public class library JARs in a fixed directory, divide the class, do not lose in a folder, such as Jakarta-Commons, Hibernate, Spring, Struts, etc. These are the source code. It is necessary to use when building, there may be some no need to play in, such as servlet.jar. If you have your own Framework, you will be placed here. Then, open Eclipse, enter Windows-> Preferences-> Java-> User Libraries, add a book, such as MYLIB, add all the public JARs all, so there is a good place, in the Eclipse project, no need See the annoying long JAR list, which is more tidy. Official to do: 1. Create a new Java Project, do not choose some of your J2EE plugins to have some options to be simple. 2. Create a few folders in root, we can often see these in the open source project downloaded online, such as: SRC - Source Classes - Compile Web - JSP and other lib - libraries, here you can simply put the east under Mylib East COPY came over to release the source code in the future. DList - Of course, we have to build a build.xml, and an ant small icon will appear in Eclipse. After this file is established, the next project is simple COPY, and it is possible to change it. 3. Open the properties page of the project, in the Java Build Path library option, join our custom public library MYLIB. As for the builders, you don't have to change it. Use the default Java Builer, I just use Ant when the project is deployed. The usual tired work will be handed over to the IDE. 4. Heavy weight, write your build.xml, online article is very sea, I will no longer be more than, basically in the number of tasks: 4.1 To declare some path variables, such as , you can also write it to the Properties file, reference here; 4.2 Declaration of class paths, as follows:

s

......

4.3 Empty Output Directory, such as web, dlist, etc.

4.4 Compilation Construction:

< Mkdir Dir = "$ {Weblib.dir}" />

...

4.5 Made WAR

4.6 Take a few tasks together and get a default target

After completing the job. In practice, some configuration files, such as struts-config.xml ibatis and spring XML can entroy JAR files, Spring resource files are not good, have a separate copy to Web-INF / CLASSES, in addition, your web Under the folder, you have to put a good Web.xml in advance, and some TLD files.

转载请注明原文地址:https://www.9cbs.com/read-62325.html

New Post(0)