I’m testing an API and get all data from the DB. I save the response as I get a json as response. I want to get the length of json array. So, if I have 2 rows in DB, I want to get 2 as a result. Or is there maybe another way to count number of rows which are
EnableConfigServer is not working for native location in spring boot
I am trying to configure a configuration server for all the properties in our application using @EnableConfigServer in spring boot. Please see the code below : pom.xml application.properties Copied all the property files to : /Users/Sankest/StarterProjects/MicroServices/AllConfigurations/ But when I try to access url at http://localhost:9090/config-server/default I am not seeing any property files and getting the following response: Answer Correct value
org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type ‘text/xml;charset=UTF-8’ not supported for bodyType
using Java 11, SpringBoot 2, WebFlux, WebClient and Jackson trying to use Spring WebClient to consume a Web service endpoint that returns XML, content type: ‘text/xml;charset=UTF-8’ Jackson XML dependency in the project’s pom.xml: WebClient code that triggers a request to external API and builds the response: ServiceResponse class (a simple POJO): resulting error: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type ‘text/xml;charset=UTF-8’ not supported for
How can I access the results from spring actuator healthcheck in Java code?
I’ve setup a healthcheck actuator with the endpoint /actuator/health, which produces something like the following for my application when you go to the URL: Is there a way I can access these results in my Java code using the Spring APIs? I’m monitoring for any that go down and sending out slack notifications when they do, I’m particularly interested in
Spring Boot Error @Autowired RestTemplateBuilder with junit
Trying to @Autowired a RestTemplate in Spring Boot 2.1.4 using RestTemplateBuilder. When i run junit tests i get an error when trying to autowired RestTemplate. I saw here: How to autowire RestTemplate using annotations It seems that RestTemplateBuilder is better so i would like to use that. This is the configuration file : This is the test class: The error
Does hibernate SessionFactory.openSession() wait for a database connection to be available from pool
Does hibernate SessionFactory.openSession() wait for a database connection to be available from pool ? I assumed it did, but I have customer with this exception org.hibernate.exception….
How to extract claims from Spring Security OAuth2 Boot in the Resource Server?
I have an Authorization Server built in .Net Core Using Identity Server 4! It is working as expected to authorize clients and resources from Node Js and .Net. Now I’m trying to add a Java spring Boot 2 API (jdk 1.8) as a Protected Resource. I have achieved that goal by using the OAuth2 Boot Documentation! Everything works fine so
Java interceptor not getting called
I have a Spring boot application and I am implementing and interceptor in order to log some data. The problem is that is not getting called, I have tried: And then I’ve applied to methods or classes and in both of them doesn’t work: Or Does someone knows what I am doing wrong? Thanks Answer If you are having a
java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl , when throwing BadRequestException
I have a handler class in my springbootapp that performs some validation on incoming REST requests and throws BadRequestException back to the controller class. But instead of controller catching the BadRequestException, it catches Exception and throws java.lang.ClassNotFoundException: org.glassfish.jersey.internal.RuntimeDelegateImpl I spend some time looking around for solution but dont seem to find any. Here is my validation code in handler Here
Set default Transaction Manager in @Transactional annotations?
I have a Spring Boot 2.x application with JPA/Hibernate and 2 separate Transaction Managers: 1 per-tenant and 1 application-wide. All entities, repositories and services are separated in different packages. Whenever I use @Transactional in my services, I need to explicitly qualify the txManager as either @Transactional(value = “tenantTransactionManager”) or @Transactional(value = “applicationTransactionManager”). This is very verbose and error prone since