Relative Content

Tag Archive for spring-boot

springboot application handle application startup errors

I am creating a standalone java application, application will be used by novice users, we will be sharing a set of error codes for trouble shooting the application. The requirement is to customize the error message, if the spring boot application failed to start with errors.

Failed to Parse Configuration Class in Spring Batch with MongoDB – Missing Setup?”

package com.example.Study.Hall.Management.controller; import com.example.Study.Hall.Management.model.Student; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.support.RunIdIncrementer; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.support.MongoJobRepositoryFactoryBean; import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.data.MongoItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.mongodb.MongoDatabaseFactory; import org.springframework.data.mongodb.MongoTransactionManager; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.transaction.PlatformTransactionManager; import java.io.FileInputStream; import java.io.IOException; import java.time.LocalDate; @Configuration @EnableBatchProcessing public […]

Spring boot test can not cast GenericWebApplicationContext

I’m new with spring boot. I follow clean architecture with spring boot in this link https://www.baeldung.com/spring-boot-clean-architecture In this tutorial, spring context load bean with bean factory. Then when I want to test API with MockMvc. I write test class follow this:

Is there anyway to access the configurable values

public class HumanAgentSocket extends TextWebSocketHandler { @Value(“${human.agents.available}”) private int availableHumanAgents; private List<WebSocketSession> sessions = new ArrayList<>(); private List<String> sessionIds = new ArrayList<>(); private HashMap<WebSocketSession,WebSocketSession> socketConnections = new HashMap<WebSocketSession,WebSocketSession>(); private int noOfHumanAgents = 1; private ObjectMapper objectMapper = new ObjectMapper(); @Override public void afterConnectionEstablished(WebSocketSession session) throws IOException { if (noOfHumanAgents<=5){ System.out.println(“Agents “+availableHumanAgents); sessions.add(session); sessionIds.add(session.getId()); System.out.println(“List “+sessionIds); […]