Skip to content
Advertisement

Tag: spring

How to set a Spring profile to a package?

I want to set a profile name to a whole package and I don’t know how. If where is no easy way then I have to mark every class in the package and sub packages with @Profile annotation. <context:component-scan/> tag does not support attribute like profile so I have no idea. Answer If you don’t mix XML and Java config

What is the difference between Transaction manager and Entity Manager

As a student, i read nearly all spring documentation. As far as i understood that spring is configuration monster. Annotation based or Xml based, it doesn’t matter but what i really don’t understand is what is the difference between transaction manager and entity manager. If we have injected entityManager on Dao layer, why do we need transaction manager on service

intellij incorrectly saying no beans of type found for autowired repository

I have created a simple unit test but IntelliJ is incorrectly highlighting it red. marking it as an error No beans? As you can see below it passes the test? So it must be Autowired? Answer I had this same issue when creating a Spring Boot application using their @SpringBootApplication annotation. This annotation represents @Configuration, @EnableAutoConfiguration and @ComponentScan according to

How to send an email to multiple recipients in Spring

The email gets sents only to the last email address in the String[] to array. I’m intending to send to all email addresses added to the array. How can I make that work? Answer You have the choice to use the following 4 methods. I have provided examples of the two methods useful in this case. I have consolidated this

HibernateException: Couldn’t obtain transaction-synchronized Session for current thread

I’m getting the following exception when trying to use my @Service annotated classes: The way I initialize my application is complicated so I need to provide a link to the full base code to get additional information: https://github.com/dtrunk90/webapp-base. I’m using this as a maven overlay. And here is the necessary code: Initializer (from webapp-base): Initializer (from my webapp): @Configuration (from

How do I inject a logger into a field in the sample spring boot application?

What I want is to make spring autowire a logger. So, in other words, I want to have this working: Right now it throws an exception at startup: “No qualifying bean of type [org.slf4j.Logger] found for dependency…”. My pom.xml dependencies: I read this: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-logging It says if you use one of the starter poms (I do) Logback is used –

javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional

I don’t understand what is the actual difference between annotations javax.transaction.Transactional and org.springframework.transaction.annotation.Transactional? Is org.springframework.transaction.annotation.Transactional an extension of javax.transaction.Transactional or they have totally different meaning? When should each of them be used? Spring @Transactinal in service layer and javax in DAO? Thanks for answering. Answer Spring has defined its own Transactional annotation to make Spring bean methods transactional, years ago.

Advertisement