Question

New to java and trying the REST. My project has two identical classes but on different packages.

For example,

 com.domainA.Person {
 }

 com.domainB.Person {

 }

Person from DomainA is posted from the client side while on the Server side DomainB.Person is used as Parameter that receives data from DomainA.Person. This is a spring REST POST call. Is this possible or I need to use same class in both the places?

Was it helpful?

Solution

OK Based on the info if you have separate projects for server and client. I would suggest that you create a project called lets say "Common". Which can have these classes which are common to both projects. This way you will have only one copy.

Both the projects will have to depend on this third project called common.

In case you don't want to or for some reason cannot use a common project you can use separate copies of Person class in different packages. But that is duplication of code and may not be considered best practice. if you can spend time to tweak your project setup so that you have one common project it will pay in long run

I hope it helps :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top