Skip to content
Advertisement

Tag: spring-boot

How do I write a test for a service that uses other services in Springboot?

I have a BookManagementService that uses the @Autowired implementation of three other services, like so So how do I mock the aforementioned services and their repo in the BookManagementServiceTest? When the test start running and it gets to the yearService layer, it throws a NullPointerEXception cause the year it receives is null The BookManagementServiceTest Answer You just have to mock

Spring boot – Snowflake JDBC – Alter session automatically when application loads

I’m trying to connect Snowflake to Spring boot based application. Everything works well however due to some crazy defaults in snowflake, I’m having to deal with the below error: https://community.snowflake.com/s/article/SAP-BW-Java-lang-NoClassDefFoundError-for-Apache-arrow I can fire the queries via Spring data JPA but not able to map the results at all. The solution asks for changing the default resultset format from ARROW to

Maven: library module

I’m working on a project with a library module that has about 10 submodules. For the application project the developer asked us to find a way so that they can import only one dependency, instead of the requested 10. Let’s use as an example the dependency of log4j: I need only to include one not all the sub-dependencies. How can

Getting Exceptions while running a Spring boot app with elasticsearch

I was following this tutorial: https://www.youtube.com/watch?v=IiZZAu2Qtp0&ab_channel=LiliumCode and the only changes I made were that I was using maven with eclipse instead. The rest of the code is exactly the same. When I run the app I get: My elasticsearch.yml: I have tried out searching the exceptions online but nothing seems to work. Please help me in figuring this out. Thank

Mapstruct how to initialize fields

I have a DTO like this and an entity I want to create a mapper to map DTO to entity. How can I make the field private Instant timestamp; has value like Instant.now()? My mapper so far It got compile error Answer The issue is due to the source being empty. Remove the source and use expression instead of defaultExpression.

Advertisement