I have a class Health Check – as part of the class I record how many parasites are seen (enum NONE, SOME, MANY) and also the location of the parasites (enum HEAD, FEET, BODY). Two ways this could be done: METHOD 1 Health Check Parasite Or I could have: METHOD 2 Would method 1 require @Entity on parasite class and
Tag: spring
How to throw an exception if required properties have either null or empty values?
I want to throw an exception when I parse the received object to a DTO and while parsing if any of the fields in DTO that I have marked as required has null values then I want to throw an exception with 400 response. I have a controller like this, I have marked a few properties in my CustomDTO as
Fetch list of forms that are belong to a specific student
I have a class of Form and Student. A student may have 0 or many forms. I set the relation between them as OneToMany. Now, I need to fetch the forms that are owned by a specific student. I have two questions at that point. How should I fetch those forms in the URL? Let’s say I want to fetch
Application Failed to start The Dependencies of some of the Beans form a cycle… Why?
so I have this section of code in AppConfig.java: if I get rid of the @Lazy it will not start, i have tried to get rid of the constructor and do: same thing, can someone please help me out, I really don’t want to have to use the @Lazy Implementation. here is the error it returns: When getting rid of
How to write JUnit 5 test cases for the following code?
This is the method to write the JUnit test cases for Inside the LoanApiCallEntity class these are the following: This is the test case I have tried, but it shows an error: The error shown while running the project (mvn test) is – LoanApiCallEntity cannot be returned by getAllApiCallDetails(). Answer getAllApiCallDetails() returns a list of objects so you need to
Can I use Azure Event Grid topics to communicate domain events in a microservice architecture?
I am confused. When comparing the messages services offered by Microsoft Azure, we can choose between: Event Grid Event Hubs Service Bus (Azure Cache for Redis) This link gives the following comparison: Now I’d like to write a microservice application consisting of several components. Each component should communicate local domain events to a topic (pub/sub). This could be achieved by
Merging two Spring Application Context without closing the first application context
In our application start-up, we are creating one application context having its own bean configuration xml. Then depending up on certain logic, we would need to dynamically load/import the second bean configuration into the existing application context. One option is to close the existing application context and creating a new application context by importing both the bean definition xml files.
Garbage collector vs IOC
Today I attend the interview I am a newbie to java, spring boot. The interviewer asked the question about garbage collectors. I said the garbage collector will release the unused resource. Then he asked about the IOC container, I said it take control of object creation and will inject into the dependent bean. Then he asked why we need to
In Spring Boot, Can we add @Service Annotation for Interface? if that interface is not implemented by any class
I created a interface which has not any implementations Can MyInterface be annotated by @Autowired? following error displayed when it run Answer No you can’t, because Spring tries to instantiate it to create a Bean (@Service), but it’s an Interface, so thats not possible.
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