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