"Eclipse" Eclipse common operations

Source: Internet
Author: User
Tags tomcat server

"Article index"

(1) Pojo class auto-generation getter and setter method

(2) automatic generation of construction methods (constructors)

(3) automatically generate its interface through the class

(4) automatic generation of JUnit test classes

(5) Custom View

(6) Customizing the new option

Body

(1) Pojo class auto-generation getter and setter method: s

Persion.java The original code:

Right-click in the blanks of the above code, or right-click on the person class name, source–> Generate Getters and Setters, as:

Next, in the Generate Getters and Setters dialog box, select the property ID of the persion and the name hook, or click the "Select All" button directly to check all the properties, and click OK.

Let's look at the code for the Person.java class:

Visible, getter methods and setter methods are automatically generated, more convenient than one to knock code.

(2) automatic generation of construction methods (constructors):

Right-click in the blank of the class code, or right-click on the class name, source–> Generate Constructor using fields, such as:

In the Generate Constructor using Fields dialog box, hook up all or part of the Persion class, and click OK. Such as:

Come down and look at the construction method you generated, see the selected section:

(3) Automatically generate its interface through the class:

In spring applications, it is often used in the form of "interface + implementation Class", that is, to implement the class and write a method of the same interface, sometimes feel more cumbersome. In fact, eclipse can automatically extract interfaces based on classes.

The code for Personserviceimpl.java is as follows:

Right-click in the blank of the above code, or right-click on the Personserviceimpl class name, refactor–> Extract Interface, such as:

In the Extract Interface dialog box, enter the interface name in the Interface Name box: Personservice, select the Addperson and Queryperson methods, such as:

After the click OK, you can automatically generate Personserviceimpl.java interface class Personservice.java, such as:

And then look at what the Personserviceimpl class code has changed:

(4) automatic generation of JUnit test classes

Right-click on the class name –> new–> other, such as:

In the New dialog box, select Java >> junit >> junit Test case

In the New Junit test Case dialog box, fill in the test class name, here, by default (Personservicetest), if you do not want the test class to be placed under the same package as the Personservice class, you can select the specified package to hold the test class This is also handled by default here. Such as:

Click Next to enter, and the method to be tested is checked, and finish will be.

If the test class was first built, it would require the inclusion of JUnit's jar package, and the click OK. Such as:

At this point, the JUnit test class Personservicetest.java is automatically generated, such as:

We just need to modify the method body of the test class to test it.

(5) Custom View

Pre-Custom View:

Window–> Show view–> Other in the menu bar

Go to the Show View dialog box, where you select the view you need to display, and click OK.

For testing, I chose several common views, such as: Java/package Explorer, Data management/data Source Explorer, general/internet Web Browser, General/co Nsole and so on.

Once customized, we drag and drop it where we want it to be, and display it as:

(6) Customizing the new option

The original new option:

If we need to build the file type is not in the right option bar, it is necessary to click "Other" into the next dialog to choose, there is no way to make the right side of the options bar appear we often need to build the file type, and remove those infrequently used?

Point window–> Customize Perspective:

Enter the Customize Perspective-web dialog box, select the Rightmost tab shortcuts, select New in submenus, then the list below, if selected, indicates that it is displayed in the new menu item. Let's go one by one, select the display, and remove the display.

The new option after customization:

Just show us what we use, and it's a lot simpler.

(7) Configuring the Tomcat server

Here is an example of configuring Tomcat 6.0.

Select the runtime environments under server:

Click on the "Add" button on the right, enter the "New Server Runtime Environment" dialog box, select the version of Tomcat we want to configure, here is the Tomcat v6.0, note that you want to match the version you downloaded.

After next enter:

From the browse button on the right side of Tomcat installation directory, click on it, go to the Local disk directory, select your Tomcat installation directory, as follows:

Once you are sure, go back to that dialog box and click on the Installed JREs button on the right side of the JRE to enter the interface:

If the JDK is already configured here, directly select OK, and if not configured, click "Add" on the right to add a standard JRE

Next, click the Directgry on the right to browse the local file system and locate the JDK's installation directory.

Okay, OK –finish, next, finish. Such as:

(8) New project, add Jar package, run.

In general, we use this tool to do Web projects, build a Dynamic Web project it:

If there is no dynamic Web project in the options, you can find it at the bottom of the other, or show it here by customizing the menu, and see my [Illustrated Tutorial]eclipse: Customizing the View with the new menu item, for how to customize the menu.

Enter the interface, enter the project name in Project name, named "HelloWorld", and select the Tomcat 6.0 server we configured earlier in target runtime. Such as:

All right, done.

about how to introduce the external jar package into our project, this is actually very simple, copy those jar files, right-click in the Lib directory.

The Eclipse for Java EE approach differs from MyEclipse on how to run a Web project.

Enter to find the server we configured:

Next–> finish.

"Original Address"

Http://www.blogjava.net/rongxh7/category/39849.html

Thanks to the original author!

"Eclipse" Eclipse common operations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.