Tim Holloway wrote:Well, for my JPA webapps, I have 3 layers: one for the raw database Entities, one for CRUD/finder operations on those entities (and in some cases, parent/child aggregates), and the highest layer is for business database service logic: graphs of entity relationships organised into working sets so that they can be detached and re-attached. The two logic layers: serice and DAO , I have marked as transactional, with the transaction context being inherited. That is to say, DAO operations made on behalf of a service function operate in the transaction of the service function.
A long-running and possibly failing operation such as HTTP is something that I would try very hard to deal with before invoking the service layer. That is. in the Business layer or perhaps a special layer between Business and Database Services. I would try to avoid making in transactional. If it has to be transactional, then you are entered the realm of XA transactions and that's a whole different can of worms and required a lot more transaction support than the basic JPA transaction system provides.
Tim Holloway wrote:Here's a general rule on how to work with the forum:
Ideally, someone should be able to pull up this page in 5 years or so (and people often do exactly that!), print it out on paper and be able to make sense of all the questions and answers. Editing in-place and offsite links both interfere with that ability.
Which is why we discourage them. It may be less efficient to do it the way we suggest, but sometimes efficiency isn't the goal.
Tim Holloway wrote:I may be showing my blindness again, but I don't see dependencies for Springfox in your POM. But despite that, you seem to have a reference to it in your Maven repository cache. Is that the actual POM that you are using?
Mohammed Sardar. wrote:Could you confirm whether Controller & Service are placed in the same package where @SpringBootApplication class in placed ?
I faced this kind of issue once before.
Dave Tolls wrote:If you want that service to be autowired in, then I'm pretty sure you have to annotate it as @Autowired.
Edit: that is, in the Controller.