I have a spring-boot project called carrental-crud with an h2 memory database, and I want to access one of the endpoints from another project called carrental-api. I use webClientBuilder for this on my other endpoints, but it is throwing status 500 with bad request when I try using it in postman. I use JPArep…
Tag: spring-boot
Is it possible to instrument a program that also uses dynamic bytecode generation?
I am writing a Java instrumentation program that uses the built-in Instrumentation API with Javassist (v3.26.0-GA) to intercept all the method calls in the target program. Also, I have implemented a REST API service inside this program using Java Spark to send requests for starting/stopping instrumentation by…
How to solve error: package org.springframework.context.annotation does not exist import org.springframework.context.annotation.Bean?
After updating the gradle wrapper to version 7.3.2 I get the following error when trying to build my spring boot project: Why is this happening? Update: Found the problem, but do not know how to fix yet. I have multiple modules in my project. I have a “common” module which is used by other modules…
Set value for private final static inlined variable using Mockito
I’m trying to test a method which calls another method which makes use of a private final static variable initialized inline. I’m then trying to change the value for the variable when the tests run. I’ve been trying things such as spring reflection or adding a setter for that specific field …
Make a POST with JPA with existing data
I have the following problem, the thing is that I have an entity: The thing is that this back is connected to an Oracle DB, in which I already have a few registered users, but these are entered through a Mockaroo script, and when I try to save a new user through a service Rest throws me this error: Of
Why this API is forbidden for an user having a JWT token containing the “correct” authority?
I am not so into Spring Security and JWT token and I have the following doubt on a project which I am working on. Basically I have this SecurityConfiguration class containing my Spring Security configuration, as you can see it is intended to handle JWT token: As you can see in the previous code I have the fol…
JPA Cast BigDecimal as string
I’m using JPA to query a database, but something strange happens. In some cases the cast works and compiles fine, but with a BigDecimal it doesn’t let me use the cast to make a LIKE with a String. Here is a part of the code that works: pesoObjetivo is a data type Double But when I try to perform t…
ReactiveMongoRepository can’t save to database
I’m newbie with Java. I’m create an API with Webflux and ReactiveMongoRepository. I try to save my data from another API. My repository: My service implements: My services: My model: After function findByIdAccountsApiTrack() run I can’t find any document created in my database. I can see my …
Spring Boot thymeleaf bad request 400 instead of showing user error
I am trying to submit a form using post request and first validate inputs. However when I make bad inputs (for example all empty) instead of showing error I get bad request (400). For showing error I am using th:if and th:errors tags in HTML. If I submit all valid inputs, there is no problem. Controller class…
Failed to load ApplicationContext for a java based config test
I want to test the Repository-Layer of my SpringBootApplication, but it fails to load application context. By the way I am using Java 17. Here is the error Here is My simple test class. Here is the application.properties file And finally here is my pom.xml Configuration for webclient bean I checked out differ…