Skip to content
Advertisement

Tag: spring-boot

Error parsing JSON (MismatchedInputException)

I’m having problems parsing JSON, this is the error: And I know why it is happening I just don’t know how to fix it. This JSON works: This one does not: The problem seems to be the { character in front of the info field because with [ works. So this is the method I’m using to parse the JSON:

Cannot invoke findByEmail because “this.userRepository” is null error

I keep receiving a Cannot invoke “com.***.repositories.UserRepository.findByEmail(String)” because “this.userRepository” is null error everytime I try to process my /register method. I can’t figure out why the code is coming across as null. Controller – Axios call – My UserRepository – Answer Simply add @Autowired to your related fields you want to get Autowired by spring. Change your code from to

How to use @ConfigurationProperties with Records?

Java 16 introduced Records, which help to reduce boilerplate code when writing classes that carry immutable data. When I try to use a Record as @ConfigurationProperties bean as follows I get the following error message: How can I use Records as @ConfigurationProperties? Answer Answering my own question. The above error raises from Spring Boot not being able to construct the

How to log the number of available/used threads in a spring boot (tomcat) based application?

Is there a spring boot config where you can log the number of available/used threads the app server currently has? Answer You can use the actuator framework. Then you have to enable tomcat JXM metrics in application.properties and expose the metrics endpoint The go to http://localhost:8080/actuator/metrics/ and you will see all the available metrics. For example current threads http://localhost:8080/actuator/metrics/tomcat.threads.current

Problems with launch spring boot jar on ubuntu server. Error starting ApplicationContext

I have configured nginx to fit my code. My code works well on Windows and now I’m trying to deploy it to Ubuntu. I run jar and it fail. Logs: My propeties: continues code: upload.path=home/kirill/uploads #properties for MailSender #smptps – Not secure connection spring.mail.host=smtp.yandex.ru #test spring.mail.username= HIDED EMAIL spring.mail.password=password spring.mail.port=465 spring.mail.protocol=smtps mail.debug=false recaptcha.secret=hided secret spring.session.jdbc.initialize-schema=always spring.session.jdbc.table-name=SPRING_SESSION hostname= HIDED HOST server.port=80

Advertisement