Skip to content
Advertisement

Tag: spring

JUnit4 failed to load application context

I am trying to use JUnit4 for testing of my project. I have tried using JUnit5 but I cannot get this working either. I am trying to test my account controller at the momemnt. This is the full stack trace of the error I am receving Here is my build.gradle: } This is the version of spring boot I am

Use public key fingerprint in Java Spring Boot application to solve “The authenticity of host ‘xxxx’ can’t be established”

I have a Java Spring Boot application which is using the spring-integration-sftp dependency to connect to an SFTP server. I get an error The authenticity of host ‘xxxx’ can’t be established and I know this can easily be rid of by setting the sftpSessionFactory.setAllowUnknownKeys(true), but that is not a good practice and I would rather not do that. I have

@PropertySource fails to autowire required class (Spring Boot 2.3.8.RELEASE)

I have the following class I plan on using to autowire an instance of a Spring class named AADAppRoleStatelessAuthenticationFilter: Although the default-integration.yml file is well placed under /resources (no ‘FileNotFoundException’ is thrown), it seems like during the application start-up, Spring, for whatever reason, is not able to read it’s content (or disregards it while trying to initialize aadAppRoleStatelessAuthenticationFilter). It throws

@JsonProperty not working after springboot upgrade

I recently upgraded my application from Spring Boot 1.5.3 to Spring Boot 2.3.5. One of the feature on UI started breaking and I found while debugging that the json response to UI had changed Original response: New response: having underscores (_) in attribute names It seems that the @JsonProperty is not working. My classes are as below: I tried @JsonCreator(mode

Conversion Error on LocalDate attribute when form-data request is sent to a Spring boot application

I send a form-data request from the Postman to a spring application. The LocalDate field in the Spring application as a text field from the form-data. I got a Conversion Error. Field error in object ‘vehicleDto’ on field ‘leasingExpiry’: rejected value [2021-01-01]; codes [typeMismatch.vehicleDto.leasingExpiry,typeMismatch.leasingExpiry,typeMismatch.java.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [vehicleDto.leasingExpiry,leasingExpiry]; arguments []; default message [leasingExpiry]]; default message [Failed to convert property value

Junit Force to throw Exception on method call

I am trying to throw the exception whenever simpleJdbcCall.execute(namedParameters) called but I see it is not throwing the error, is there something i am missing here ? Here is my class here is my Junit Class Answer When writing spring-boot integration test you should inject the mock beans using @MockBean annotation You can a follow some of the examples here

Getting Picocli to work with Springboot application

I have to convert a large Spring boot application into a flexible CLI tool, where the requests sent by the Spring boot application (among other things) are determined by user input at the command line. I decided to use picocli to implement the command line functionality, however I can’t figure out how to even do something as simple as print

Advertisement