Java Development using Eclipse-maven-git (4)-a more detailed introduction to eclipse

Source: Internet
Author: User

Although the previous blog has introduced the installation of Eclipse and some configuration, at the end of this article has been said to begin to explain how to build a project in eclipse, began to write code, but later I found: Some details are not mentioned, and for the Eclipse window layout, perspective, views, associated with other software (MAVEN, Tomcat, etc.) and so on not mentioned or vague, beginners certainly all kinds of confusion, but my blog of this series is not for beginners, so that they can start with a reference!! So, I decided that this article should not tell you how to build a project in Eclipse, write code, but first explain the basics of Eclipse's perspective, view, window, how to correlate other software, and so on.

On a blog, in said how to configure the time there are some, the figure also has some explanatory text, roughly also understand, but there is no separate writing to explain, the following content, I try to combine text and text, the purpose is to let beginners also know how to operate, if you will use eclipse words, This blog post can be skipped directly .

0. Prerequisites

Although this article is a basic aspect of the introduction, but also need to finish the previous blog requirements of the installation steps, specifically: Installed JDK, maven,eclipse can start normally, and installed the above mentioned plug-in.

Of course, it's OK if eclipse can start up normally. :)

1. The composition of Eclipse

Speaking of this composition, it is not simple to say where the window is what can be done, I do not intend to say that, I would like to say is the eclipse of the software, some of the composition, not just what you see.

As we all know, Eclipse was originally IBM took a lot of effort to do, the purpose is to make a good IDE out, and although it is written in Java, but the purpose is not only the Java IDE, then IBM open it up, after continuous development, it is now the way it is. Because the original design is to be extensible, so the entire eclipse is a large plug-in platform, all the "function" is provided by the plug-in, and then the official integration of some plug-in package, there are various different applications for different areas of the use of packages, and due to the increase in the type of plug-in, Now Eclipse is really a comprehensive IDE that can complete a variety of software development, as long as you install the right plugin!

Not only the official supply of a large number of plug-ins, other companies, communities have also provided a large number of plug-ins, such as: Oracle Oepe is based on the integration of WebLogic developed plug-ins, STS is based on the eclipse of the integration of spring-developed plug-ins, Many people have used myeclipse, as well as JBoss to provide an integrated version, as well as Android-developed ADT (it seems that Google will no longer provide updates: (), there are many other, not listed. Of course, the Eclipse Plugin development method is also open, if we have the need for ourselves can also develop plug-ins to use. On the whole, the Eclipse architecture is a basic platform, then integrates the various plugins above.

Talking about how Eclipse works, let's talk about what eclipse is showing and what it can see. Eclipse's interface is made up of many "views", which are the functions of the corresponding plug-ins, and of course, not all plug-ins have corresponding views, depending on the plugin, but the view has a corresponding plug-in. Then some plug-ins are combined to form a "perspective" (perspective), and the Eclipse interface we see is a perspective view.

2. View

One view looks like this:

Yes, this "Project Explorer" is a view, similar to the following:

Of course, this is a few views and together, each "tag" is a view, the view can be dragged, change position, order, size, and so on, each view has a corresponding function.

When we first started using it, we found that there was a view we needed that didn't show up, and we could let it show up:

Menu bar, "Window->show View->other", in the pop-up dialog to find the view you want to display, to select multiple words can use the shift or the CTRL key, and select the file is similar to the operation, select OK then click OK.

3. Perspective view

As has been said, the perspective is a lot of views, see the eclipse of the entire interface is a perspective, we can switch to other perspectives, a perspective is often specialized in the application with a certain scene, such as "Debug" this perspective, I believe you should know, This is the perspective at the time of the debug operation.

Switching between different perspectives can be as follows:

The menu bar, "Window->perspective->open perspective" can be selected directly from the list, or you can go to other in all available perspectives. In addition, the following method is also good:

In the upper-right corner of the window, the button in front of the current perspective name is the button that selects the perspective, and a pop-up box appears after the click to select it.

The view of the perspective is pre-organized, we modify it as needed (layout, add, remove), you can save it for later reuse, (the modified perspective is not saved after closing and re-opened will be restored), the method is described in the previous picture, "window-> Perspective->save perspective as "to save the current perspective.

4. Associated Server runtime Environment (Tomcat)

The Java EE edition of Eclipse provides functionality in operations such as deploying and starting a server, but the specific server operating environment requires a separate installation configuration, as illustrated by the following installation of Tomcat.

4, 1 installing Tomcat

First of all, to download Tomcat, this depends on the system type, but remember to download the uncompressed version, Windows do not download EXE installation version, I downloaded the apache-tomcat-8.0.20.zip. Then extract the folder in the file to a relatively fixed location, preferably not a space or Chinese characters or other special symbols, I extracted to the D packing path.

4, 2 Configuration Association

In Eclipse Preferences, locate "server", expand and click "Runtime xxxx" on the right "add",

In the pop-up box, select the type of server we want to associate, here we select "Apache->tomcat 8", then tick "create new XXX" below and click Next


To the new window by browsing to find our prior to the server directory, remember, directly select the server extracted from the directory on the line, do not choose to other.

Once associated, a record is generated in the server view, and a record is also generated in the Project Exploer view, which is the relevant configuration, which is described later in the specific use.

5. Install the associated MAVEN

This series of blog post maven is a key point, about what it is, what it can do, what good it is, why it is chosen, and so on, I don't want to say, we can Baidu by ourselves. Here's a look at the installation of Maven and the associated configuration in Eclipse, among others.

5.1 Download Install Maven

The MAVEN program is provided by the Apache Foundation, which can be run based on the Java environment. This demo uses the 3.2.5 version:

http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/http://mirrors.aliyun.com/apache/maven/maven-3/3.2.5/binaries/

Windows please download the zip file, I download here is "Apache-maven-3.2.5-bin.zip", the file extracted to a no space, no Chinese and other special characters in the path to save, I extracted to the root of the D drive directory.

5.2 Configuring the MAVEN runtime Environment

Maven needs to be run by the Java Runtime environment, since already seen here, about the Java configuration is not said. Let's talk about MAVEN configuration alone.

Need to create a new environment variable "Maven_home" value for the installed MAVEN root directory, here I am:

D:\apache-maven-3.2.5

This needs to be adjusted according to the specific path, and then you need to modify the value of the "path" environment variable, appending the following:

%maven_home%\bin;

Once set, start the command-line tool and run the "mvn-v" output similar to the following to indicate correct:

5.3 Configuring Maven repositories and Caches

While it's straightforward to say that Maven is ready to run, it can be optimized, and I think it's important to do this: modify the local cache location, modify the default warehouse configuration.

Locate the MAVEN configuration file:

<maven_home>/conf/settings.xml

Open edit, there are many configurations in the file, but all are commented, because these configurations are the default values used, and each configuration has comments, our configuration in this file will override the default configuration.

Find one of these:

<!--localrepository |   The path to the local repository maven would use to store artifacts.   | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository>-

Add the local cache's storage path behind it (note), like this

<localRepository>E:/Workspaces/mavenrepo</localRepository>

Remember, the path uses Linux-like notation (using/not using \), and this path will cache the Maven artifacts later, requiring long-term storage.

Found it:

  <mirrors>    <!-- mirror     |  Specifies a repository mirror site to use instead of a given  repository. the repository that     | this mirror  serves has an ID that matches the mirrorOf element of  this mirror. ids are used     | for inheritance  and direct lookup purposes, and must be unique across the  set of mirrors.     |    <mirror>       <id>mirrorId</id>      <mirrorOf> Repositoryid</mirrorof>      <name>human readable name  for this mirror.</name>      <url>http://my.repository.com/repo/path</url>     </mirror>     -->  </mirrors>

This configuration is the warehouse information, we can specify from which warehouse to download the required components, can be configured multiple, this configuration can see the OSC of the Maven warehouse help: Http://maven.oschina.net/help.html

The configuration looks like this (I'm configuring my own local agent):

  <mirrors>    <!-- mirror     |  Specifies a repository mirror site to use instead of a given  repository. the repository that     | this mirror  serves has an ID that matches the mirrorOf element of  this mirror. ids are used     | for inheritance  and direct lookup purposes, and must be unique across the  set of mirrors.     |    <mirror>       <id>mirrorId</id>      <mirrorOf> Repositoryid</mirrorof>      <name>human readable name  for this mirror.</name>      <url>http://my.repository.com/repo/path</url>     </mirror>     -->    <mirror>             <id>nexus-197</id>             <mirrorOf>*</mirrorOf>             <name>Nexus 197</name>             <url>http://192.168.1.197:8081/ content/groups/public/</url>        </mirror>   </mirrors>

You can build your own local agent, see: Using Nexus to build a MAVEN private warehouse server

5.4 Associating Maven in eclipse

Find "Maven" in Eclipse's "preferences" and tick the options on the right, like this:

then expand "Maven", find "installations" in the expanded menu, the list on the right already has the eclipse built-in Maven support, but I prefer to use my own installation, click "Add", find the Installed folder, add it and then check it, Just like this:

Then click on the "User Settings" on the left to associate our modified profile, remembering that two files are modified:

After the modification, the cache address below will be shown as our path.

Once everything is set up, you can confirm that restarting eclipse will update the local index.

6. Summary

At this point, the series of Java, Eclipse, Tomcat, MAVEN are installed and configured, as for git to stay behind to say it, at this stage is not used, rice or a bite to eat slowly is not.

The content of this article is very basic content, for those who already have the relevant software or tool experience of the people have no meaning, but it is very helpful to people who have just contacted or ready to contact, I write these is to help those who do not know how to install, configure the new person, I hope you have some help.

Everyone in the reading if you find that there is something wrong, also please directly in the comment area to explain, we progress together, thank you!

The next article will really start writing code.

enjoy!

Java Development using Eclipse-maven-git (4)-a more detailed introduction to eclipse

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.