Eclipse builds Maven Prooject (finally), mavenprooject

Source: Internet
Author: User

Eclipse builds Maven Prooject (finally), mavenprooject

 

Today, we will discuss how to build a maven project in eclipse.

1. Create a maven project,

1. Find File and click

 

2. In the pop-up window, click new

3. In the pop-up window, click other

 

4. Enter maven, find maven project, and click next

5. click Next.

6. Find and double-click maven-archetype-webapp.

7. Enter the Group Id and Artifact Id. The Package is automatically generated and click finish.

8. Enter the Group Id and Artifact Id. The Package is automatically generated and click finish.

Note: A problem may occur here, that is, you cannot create a project, as shown below:

 

How can this problem be solved?

Simple: Because you didn't specify the settings. xml file, you can do it now by following the steps below.

In this way, you can ................

9. Click finis to create a maven project.

10. There will be a maven project we just created in the project bar. The project structure in the java view is as follows:

 

11. At this time, we will see the error does not matter. Right-click the project and choose Build Path> Configure Build Path...

12. Remove two incorrect Source folder under Source.

13. Click Add Folder...> Create New Folder... to Add src/main/java, src/test/java, and src/test/resources.

Similar steps, the final structure is

 

So OK, there may be one more...

You can.

14. Double-click the Output folder under src/test/java and src/test/resources respectively, and set the release directory of the class compiled for the test code to target/test-classes. In order not to mix together with the compilation files of the official code, use the default target/classes for the official code release directory.

 

Then, select this

Yes.

15. Adjust the folder display Order in Order and Export

 

16. Double-click in Libraries and replace the default jre with your own jre. Here I replace JRE System Library [jdk1.8] With JRE System Library [J2SE-1.5]

 

Then

Then

And then

 

Last

17. Convert to Dynamic Web project for tomcat Recognition
Click Project Facets in the left-side Navigation Pane. Select Dynamic Web Module on the right side. Set version to 2.5 (default 3.0 for java7). Click OK.

 

But we do not need to do this step, because the project we created has been automatically converted to a Dynamic Web project ...........

18. Click Deployment Assembly on the left side of the page to delete two test folder instances that do not need to be deployed.

In this way, you can .....

19. The project we have created is still incorrect because the jar package we need is missing. We need to configure the jar coordinates in pom. xml.

The jar we need is missing here. Let's configure it now, But how should we configure it? I will not download it from any official website, but it is downloaded from the Apache official website by default, you can also download it from other official websites ..

If you want to download it from other official websites, You need to configure something in setting. xml ..

 

This is the default value. You can change the path ....

The following is the false code in pom. xml:

  <!-- javaee api -->    <dependency>            <groupId>javaee</groupId>            <artifactId>javaee-api</artifactId>            <version>5</version>        </dependency>

At this time, no error is reported. You see

Now we have finished 95%. We need to run the project, so we need to configure the tomcat service and restart the service.

How can I start it?

20. Configure the service. If there is no tamcat, add it by yourself.

 

Then

21. You may not see the tomact service...

Then

Then, let's take a look.

 

Note that you have to add projects by yourself.

Then

 

Now you can start to serve La la ....... It's a great deal of hard work.

But I am very happy to share my own things with you .........

 

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.