Build a Web project using Maven

Source: Internet
Author: User

Create a new MAVEN project, note that the selection here is like creating a simple project that does not apply to archetype selection.



Next:

Then finish, the project is built. Use the Navigator view to see the structure of the currently built directory as follows:

At this point, review the configuration of project facets, and for the purpose of project facets, the following is described on the Web:

Facets can be understood as: the nature of the project, and the configuration of facets is provided by the mainstream IDE (Eclipse idea).

The default project facets is configured as follows:

These three are sufficient for the time being, but I have changed the version as follows:

After saving, it is found that there is no web directory structure such as Webinfo folder and XML. I follow the online method after the attempt, do not take effect, the final figure out the feasible method is (in fact, this step is mainly to generate Webinfo folder and Web. XML structure, do not use this method, I think I am the same new):

Select the following first:

Then click Apply, then switch back, this time, the future Configuration avaiable out, as follows:

Click on the future Configuration avaiable to choose from the following:

The directory structure is complete at this point, as follows:
Then see deployment Assembly, about the difference between deployment Assembly and OutputFolder, consult the information after the following: Output folder, is actually to tell Eclipse, after the source code compiled, class Where the file is placed, it is available in any javaproject. The deploymentassembly configuration item only exists in Java Web project.
So deploymentassembly is used to configure Web projects, and if you use Tomcat, you will find that the class files and jar packages configured in deploymentassembly are not generated in the corresponding directory in the project, which is no problem , as it was generated in the Tomcat configuration directory, as in My Computer, is:E:\eclipseworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 the following directory. After I have made the above project facets configuration, the Deployment assembly is configured as follows:

/webcontent that part is wrong, I want to use the directory is Src/main/webapp, so modify the configuration as follows:



At this point, a Web project is configured. The content under Src/main/java will be synced to web-info/classes, I just need to write the Java file in the entire directory. Src/main/webapp the following files will be synced to the root of the Web directory, I can define JSP files throughout the directory.

Now I'm adding a JSP file as follows:



An error was found because no Tomcat package was introduced into build path. Solve the problem after introduction. Then start the service. The entry URL was successfully accessed as follows:


Build a Web project using Maven

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.