简体   繁体   中英

How to mark primary/default constructor in domain layer

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.

Use the @Autowired annotation on the primary constructor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM