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
Tag: spring
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
What does Hibernate @Proxy(lazy = false) annotation do?
I was facing two different stack traces (see below) when trying to serialize my ESRBRating object which is a JPA entity. I am using Spring Data JPA. The controller called the service, service called the repository. I was able to resolve the issue by adding @Proxy(lazy = false) on my ESRBRating object. My main question is what does @Proxy(lazy =
ActiveMQ setup – Unable to send the message to Queue (error – java.io.IOException: Unknown data type: 47)
I have installed ActiveMQ and could access the url at – http://localhost:8161/admin/queues.jsp. When I try to drop a message to a queue I am getting the below error. The sample code is given below: Spring xml is: Error is: Answer The ‘Unknown data type: 47’ error is due to the configuration you are using for the following broker URL: The
Can I manually load @ConfigurationProperties without the Spring AppContext?
Is there any way to load a class marked with @ConfigurationProperties without using a Spring Context directly? Basically I want to reuse all the smart logic that Spring does but for a bean I manually instantiate outside of the Spring lifecycle. I have a bean that loads happily in Spring (Boot) and I can inject this into my other 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.