Javaweb Integrated YMP framework in Engineering (II.) _java

Source: Internet
Author: User
Tags java web

This article describes how to integrate the YMP framework in Java Web Engineering, which is based on the IntelliJ idea as the development environment, and the engineering structure is built using maven:

IntelliJ idea Download Address: https://www.jetbrains.com/idea/download/

Maven Download Address: http://maven.apache.org/

Create a project

1. Open the Idea development environment and click the Create New Project button to start creating the Project Wizard, as shown in Figure 1 below:

2. Select the left MAVEN item in the New Project window, tick the Create from archetype option, and then click the Next button after selecting Maven-archetype-webapp in the list, as shown in Figure 2:

3. After completing the GroupID, Artifactid, version coordinate information of the MAVEN project, click the Next button, as shown in Figure 3:

4. After confirming the MAVEN path and configuration and project information is correct, click the Next button, as shown in Figure 4:

5. Name your new project, click the Finish button to complete the wizard and start creating, as shown in Figure 5:

6. Maven Project creation process takes a little time, patiently waiting for the console output build success, congratulations on your new project creation completed, as shown in Figure 6:

Add Ymp Frame Dependency Package

1. Open the project Pom.xml file and add a dependency configuration as follows:

<dependency>
  <groupId>net.ymate</groupId>
  <ARTIFACTID>YMATE-PLATFORM-WEBMVC </artifactId>
  <version>2.0-SNAPSHOT</version>
</dependency>

<dependency >
  <groupId>net.ymate.platform</groupId>
  <artifactid>ymate-platform-cache</ artifactid>
  <version>2.0-SNAPSHOT</version>
</dependency>

After adding a dependency configuration, you can see that YMP dependent packages are automatically loaded, as shown in Figure 7:

If you have not yet installed the compiled YMP framework package, please check out the previous blog: "YMP development Framework for Quick Start (i): Download and compile YMP framework code"

Configure and integrate the YMP framework to Web Engineering

1. Modify the Web.xml file

The YMP framework is initialized through listener in Web engineering, and the request and controller mappings are done through the filter or servlet, so you need to add the relevant configuration in the Web.xml file, as shown in Figure 8:

Ps:

1. The Web.xml for Web projects created on MAVEN is version 2.3, which needs to be replaced with 2.4 or more versions.

2. The filter and servlet two configuration methods are provided respectively, and the filter is recommended for processing the request.

The complete Web.xml configuration reads as follows:

<?xml version= "1.0" encoding= "UTF-8" ><web-app "id=" webapp_id "version=" 2.5 "xmlns=" /ns/javaee "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" Http://java.sun.com/xml/ns /javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "> <listener> <listener-class>net.ymate.p latform.webmvc.support.webappeventlistener</listener-class> </listener> <filter> <filter-na Me>dispatchfilter</filter-name> <filter-class>net.ymate.platform.webmvc.support.dispatchfilter </filter-class> </filter> <filter-mapping> <filter-name>dispatchfilter</filter-name&gt
    ; <url-pattern>/*</url-pattern> </filter-mapping> <!--<servlet> <servlet-name> Dispatchservlet</servlet-name> <servlet-class>net.ymate.platform.webmvc.support.DispatchServlet< /servlet-class> </servlet> &LT;servlet-mapping> <servlet-name>DispatchServlet</servlet-name> <url-pattern>/service/*< /url-pattern> </servlet-mapping>--> <welcome-file-list> <welcome-file>index.html</ Welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</ Welcome-file> </welcome-file-list></web-app>

3 Adding the YMP framework configuration file

Create a new Ymp-conf.properties file (this is the only configuration file for the YMP framework) under the root path of the engineering resource Directory resources and edit its contents as shown in the following illustration:

Ps:

The Ymp.dev_model parameter, which is to set the current project to run in development mode, will output more frame logs for easy debugging.

The Ymp.autoscan_packages parameter is the package path that sets the frame to scan automatically.

Summary

To this end, we have completed the integration of the YMP framework and the Javaweb project, the next one will detail the use of the controller.

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.