Build Java Web projects and package deployments with IntelliJ idea and maven

Source: Internet
Author: User
Tags tomcat server

Love programming Love to share, original articles, reproduced please indicate the source, thank you! Http://www.cnblogs.com/fozero/p/6120375.html

I. BACKGROUND

More and more people now use the IntelliJ Idea tool for Java development, which was previously known to IntelliJ, but has never been used.

IntelliJ idea is much more useful than myeclipse and powerful, and Google Android Studio is based on IntelliJ idea.

Development efficiency is very high, a variety of intelligent tips and so on, specific people can go to understand, here I will not repeat, this article focuses on how to use IntelliJ idea and maven to create a Java Web project.

Second, download the installation

IntelliJ ideahttps://www.jetbrains.com/idea/download/#section =windows

mavenhttp://maven.apache.org/download.cgi

Install IntelliJ idea the default interface is generally the case, no toolbar is displayed, the operation is very inconvenient

Because it is the first time use, so the whole tool is not very clear, if you want to display, we click on the view, and then tick toolbar on the line

Now we can see that our tool class has a lot more icons handy

Third, Maven introduction and configuration

MAVEN is a project building and management tool that provides methods to help manage builds, documentation, reporting, dependencies, SCMS, publishing, and distribution. It is easy to compile code, manage dependencies, manage binaries, and more.
We use MAVEN to build the project, so in the future development without you manually to download the jar package, all the jar package warehouse management, just configure the pom file, Run-install ... Depending on the package will be downloaded, save you to manage the time to rely on, as well as SVN do not have to pass the jar package, can not limit the IDE, some people like using eclipse someone like to use NetBeans.

Similar project building tools and Ant and Gradle,android Studio are built by default with Gradle, which is very handy

Just getting started we need to configure MAVEN, set up maven install directory and maven local repository.

Iv. maven Creating a Java Web project

Click Create New Project

Choose to create a MAVEN project, such as

Fill in GroupID and Articfactid

Choose our Maven installation directory and the local repository

Fill in the project name, directory, and module name, etc. click Finish

Create a good project directory structure

Recources folder: Typically used to store some resource files
WebApp folder: Used to store Web configuration files and JSP pages, etc.

Note: The target directory is not generated until MAVEN is packaged, and is not available at first.

V. Create a Java directory

Click Project Structure

Select modules, select TESTMVN Project, right-click New Java Directory

Set the Java directory to sources, save the Java code, the folder will turn blue after the setting is finished, click OK

Vi. Configuring the Tomcat server

Click Edit Configurations

Click on the top left corner to add a symbol, select Tomcat server-"Local

Configure the following options click OK

If you want to deploy our program, select the deployment point to the right of the plus sign select artifact Select our Project

VII. Maven Package Deployment project

Click Maven Projects on the right to appear as

right mouse button to run Maven Build

The following results show that build succeeded

Then we choose install Run to package

When packaged successfully, the following results appear, showing the storage directory of our War packages

After that, we will generate the target file we configured in our project directory.

We copy the war package under Tomcat under the WebApps directory and run the Tomcat server

In the browser input URL display Helloword http://localhost:8080/

Build Java Web projects and package deployments with IntelliJ idea and 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.