How to mark primary/default constructor in domain layer

489 Views Asked by At

I'm writing spring-mvc app, doing frontend part now and find such problem: when user try to add something into form, for example, name of new auditory, after that should be called constructor and created new object then added to DB but exception appears:

Message Request processing failed; nested exception is java.lang.IllegalStateException: No primary or default constructor found for class university.domain.Auditory

Because I have 2 constructors for objects in domain layer, how can I mark which constructor should be used? It is not a bean so I can not use something like @Primary annotation.

1

There are 1 best solutions below

0
Václav Kužel On

Use the @Autowired annotation on the primary constructor.