Skip to content
Advertisement

Tag: spring

creating spring rest services without using spring boot

I’ve followed the Getting Started tutorial on spring.io for building REEST services https://spring.io/guides/gs/rest-service/. The problem is that this tutorial only explain how to produce a standalone running jar with tomcat embedded using spring boot. Is there a way to create a project from scratch to produce a war to deploy for instance on an already existing tomcat instance? PS: I

How to set a specific DataSource for a Repository?

Is it possible to assign a specific DataSource to a @Repository? I’d like to create a test environment where in general I want to use the test-datasource, but a few CrudRepository should operate on a different DB (the production DB; read-only operations). Can I tell spring which datasource to use for a repository explicit? public interface MyRepository extends CrudRepository<Customer, Long>

How to understand Spring @ComponentScan

I’m following a tutorial about Spring MVC and I cannot understand something about the @ComponentScan annotation even after reading the spring API doc, so here is the sample code: Configuring View Controllers Annotation-based Controllers My question is, for View Controllers, by adding @Configuration and @ComponentScan(basePackages = { “com.apress.prospringmvc.bookstore.web” }), what will be done in the background? Will the package com.apress.prospringmvc.bookstore.web

Spring JPA no transaction is in progress

I am new to Spring and JPA, wasted 5 days and no result with searching internet. I want to save object to SQL SERVER, connection is correct but when I write .flush() I get the exception nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress This is my jpaContext.xml This is my persistence.xml file: This is my Service implementation: And

How to inject multiple JPA EntityManager (persistence units) when using Spring

I need to use one database for queries (non-modifying) and one for commands (modifying). I am using Spring Data JPA, so I have two configuration classes: In my repository I sometimes need to decide with EntityManager to use like so: I am using persistence unit’s name as defined in my persistence.xml: Spring throws org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘persistence.reading’ is defined.

How to autowire properties bean from Condition

Does have anyone way to autowire bean in Condition? There is an next example. We have 2 implementation of FileManager. One of implementation should be initialize in depends on property ‘platform’. Properties handles via Archaius. . . . This code doesn’t work. Main reason is because ArchaiusProperties bean doesn’t initialized when condition matches. Does have anyone way to initialize ArchaiusProperties

Spring Boot ConflictingBeanDefinitionException: Annotation-specified bean name for @Controller class

I keep getting the ConflictingBeanDefinitionException error in my Spring boot application. I am not entirely sure as to how to address it, I have several @Configuration annotated classes helping to set up Thymeleaf, Spring Security and Web. Why is the application trying to setup the homeController twice? (and where is it trying to do this?) The error is: My spring

“Could not find acceptable representation” using spring-boot-starter-web

I am trying to use spring-boot-starter-web to create a rest service serving up JSON representations of Java objects. From what I understand this boot-starter-web jar is supposed to handle the conversion to JSON through Jackson automatically but I am instead getting this error. My Controller is this… My pom.xml has… mvn dependency:tree shows that spring-boot-starter-web does indeed depend on the

Advertisement