Java Web project References Java project

Source: Internet
Author: User
Tags java web

Since most of the company's projects now use the combination of client and service as a complete project, the communication between client and service is using spring invoke, which causes the Pojo and service interfaces to be redundant in two projects, So I'm going to refactor the code. Before refactoring, take a look at the project's overall architecture diagram:

The process of refactoring:
1. Create a new Java project with the name of any item, for example, called: Common
2. Copy the Pojo and service interface to the new project and delete the original Pojo and service interface related classes in the client and service. (After these two steps, the client and service will have a lot of compilation errors)
3. Refer the common project to the client and service respectively.
The steps are as follows: Right-click on the project-build path-configure Build path-projects Clicking the Add button to add the common project. :

After you finish the above steps, the project compiles without problems. However, when you start the project, the Tomcat returns the Pojo class is not found. An important fourth step is also required.
4, the project is packaged in a jar package to the client and service, the steps are as follows: Project right-properties-deployment Assembly-add-project select Common Project. The items are added as follows:

This will be the project Pojo and service independent, each time only modified once. When the project is deployed to a formal environment, the project is packaged into a war directly, and a jar package with a project name under the Lib directory of the war is found

Java Web project References Java project

Related Article

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.