spring-4

complete jms:listener migration to JavaConfig

£可爱£侵袭症+ 提交于 2019-12-06 01:25:17
Like the title says.. I have read this valuable How to add multiple JMS MessageListners in a single MessageListenerContainer for Spring Java Config link The author of that post is working through messageListenerContainer.setMessageListener(new TaskFinished()); BTW: I use @Autowired private ConsumerListener consumerListener; defaultMessageListenerContainer.setMessageListener(consumerListener); I am not using the new operator. OK, the restriction of the setMessageListener method is: the class must implements the MessageListener interface, I have tested and works My problem is, according with 23

multiple @ComponentScan in Spring 4?

陌路散爱 提交于 2019-12-05 22:25:22
问题 I am using Spring 4.16 with Java Annotations, and i want to do something like: @Configuration @ComponentScan(basePackages = "com.example.business", includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ServiceComponent.class)) @ComponentScan(basePackages = "com.example.business.framework") public class ServicesBaseConfiguration { } Obviusly, it doesn't compile. But i hope you get my point. I want to have multiple ComponentScans with differents packages and filters.

what is the difference between using or not Spring Beans?

老子叫甜甜 提交于 2019-12-05 13:46:38
Probably i'll get a lot of downvotes, but it's so confusing for me all this fact of whether use beans or not. Lets suppose this example interface ICurrency { String getSymbol(); } public class CurrencyProcessor { private ICurrency currency ; public CurrencyProcessor(ICurrency currency) { this.currency = currency; } public void doOperation(){ String symbol = currency.getSymbol(); System.out.println("Doing process with " + symbol + " currency"); // Some process... } } So, to inject the ICurrency impl injection i think that i can do it by two ways: Way 1: Without Spring beans public class

Spring 4 cannot execute Java 8 default methods

我的梦境 提交于 2019-12-05 03:35:13
I have defined interface public interface MyInterface { default void setOrder(int a){ } default int getOrder(){return 123;} } and implementation public class MyInterfaceImpl implements MyInterface {} In my spring configuration file I have defined following bean: <bean id="a" class="my.package.MyInterfaceImpl"> <property name="order" value="999"/> </bean> When I create spring context I got following error: Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'order' of bean class [my.package.MyInterfaceImpl]: Bean property 'order' is not writable or has an invalid

Spring4 MVC Unit test does not compile

爱⌒轻易说出口 提交于 2019-12-05 01:32:00
I have strange behaviour when trying to compile sources after Spring 3.2.5 → 4.0.0 version update. Faulty code snippet from ApplicationControllerTest.java (it is equivalent to code from documentation ): import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; ... @Autowired private WebApplicationContext wac; private MockMvc mockMvc; @Before public void setUp() { mockMvc = MockMvcBuilders.webAppContextSetup

Is there a Maven repository for Spring 4?

守給你的承諾、 提交于 2019-12-05 00:56:27
I'm looking for Spring 4.0 M1, for use with Java 8. According to this issue there should be a build, can't find however. Ideally there would be a Maven repo, but I can't even find a regular download? As of December 12, 2013 , Spring 4.0.0.RELEASE is in Maven Central. You can add this to your pom.xml to bring it in: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>4.0.0.RELEASE</version> </dependency> Quoting Paul Grays answer - Spring 4 is already in Maven central so you just need to add this dependency <dependency> <groupId>org.springframework<

java.lang.IllegalArgumentException: expecting IdClass mapping

家住魔仙堡 提交于 2019-12-04 22:25:06
I have configured composite primary key for my entity Employee as follows Employee.java: @Entity @Table(name="employee") @Proxy(lazy=false) @IdClass(EmployeeId.class) public class Employee implements Serializable { private static final long serialVersionUID = 1L; private EmployeeId employeeId; private Person person; private Branch branch; private boolean isActive; public Employee() { } @EmbeddedId @AttributeOverrides({ @AttributeOverride(name="person", column = @Column(name="person_id")), @AttributeOverride(name="branch", column = @Column(name="branch_id"))}) public EmployeeId getEmployeeId()

Error while Handling 404 error for Spring Boot REST application

跟風遠走 提交于 2019-12-04 16:51:07
I trying my hand out in Spring boot exception handling . I have created a REST application and the application works for all valid url. I am trying to handle the exceptions for invalid url. But if i try hitting the application with an invalid url , i am getting the below exception:- 13:04:02.940 [http-bio-8081-exec-3] INFO o.s.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcherServlet': initialization completed in 44 ms 13:04:03.177 [http-bio-8081-exec-3] ERROR o.s.boot.context.web.ErrorPageFilter - Cannot forward to error page for/sample/processgetMessage5 (response is committed), so

Push message from Java with Spring 4 WebSocket

扶醉桌前 提交于 2019-12-04 08:56:23
问题 I'd like to push messages from Java to WebSocket clients. I've successfully made a js client send to the server and receive a message back on 2 js clients, so the client side code works fine. My issue is that I'd like to initiate a send when events occur within the Java app. So for example every time 10 orders have been placed send a message to all subscribed clients. Is this possible? My current config: <websocket:message-broker application-destination-prefix="/app"> <websocket:stomp

Configure External Broker(RabbitMQ) In Spring4+STOMP+SockJS Application

依然范特西╮ 提交于 2019-12-04 05:32:08
I am working on a chat application developed using Spring4 Messaging and STOMP implemented with SockJS. The application works fine when I use the Simple Message Broker : config.enableSimpleBroker("/queue/", "/topic/"); But, now we have a requirement to use an external broker(RabbitMQ) with the same application. For that, I changed the above code with the following: // config.enableSimpleBroker("/queue/", "/topic/"); config.enableStompBrokerRelay("/queue", "/topic"); My client side is connecting using STOMP client as below: stompClient.connect({}, function(frame) { // subscribe to topics or