Skip to content
Advertisement

Tag: spring

package org.springframework.boot does not exist

I am trying to run a Small basic Spring boot program on my machine and I when I run clean compile (even before trying spring-boot:run) on maven I get the following Error : Here is my Pom.xml : And here is my java Class : I tried many solutions I could find on internet, such as deleting the .m2 repository,

How to print to console in Spring Boot Web Application

Coming from a Node background, what is the equivalent of console.log() in spring boot? For example I’d like to see in my console the job info in the following method. System.out.println(); is how I know to do it in Java but it doesn’t seem to appear in my console. Using IntelliJ. Answer System.out.println(job); like you have done. It prints something

Why component scanning does not work for Spring Boot unit tests?

The service class FooServiceImpl is annotated with @Service aka @Component which makes it eligible for autowiring. Why this class is not being picked up and autowired during unit tests? The test failed to load application context, Full stack trace If test class is annotated with @SpringBootTest then it creates whole application context including database connection and a lot of unrelated

Rest Controller method not getting called in spring boot

I am implementing rest webservice via a spring boot application. POM application.properties Application launcher class Controller I see Did not find handler method for [/services/account] message in the console when I fire http://localhost:8082/services/account URL in the browser as shown below I dont see message – ACCOUNT METHOD CALLED in the console meaning controller method is not getting invoked.Can you please

Is it necessary to use @Configuration while working with spring annotations

I am working with a simple spring application to check @Configuration and @Bean(java based configuartion only),The program is working with both @Configuration and without it.So is it necessary to have it. Here is my code, Student.java Faculty.java MyConfig.java Client.java The output is same with or without the @Configuration Even tried with autowiring,it is also working without @Configuration Student.java Client.java Answer

How to resolve SQLServerException: Invalid object name?

I am creating a spring boot application using MS SQL server. I have a requirement where I need to initialize USERS table in user_database database using data.sql file placed in /src/main/resources/ folder and rest of the tables should be created automatically in springboot_db database with the help of @Table annotation. Below is the code snippet. applicaiton.properties file data.sql AppConfiguration.java (One

Reactive WebClient GET Request with text/html response

Currently I’m having an issue with new Spring 5 WebClient and I need some help to sort it out. The issue is: I request some url that returns json response with content type text/html;charset=utf-8. But unfortunately I’m still getting an exception: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type ‘text/html;charset=utf-8’ not supported. So I can’t convert response to DTO. For request I use following code:

Spring Boot + MongoDB Id query

I have a Spring Boot application combined with MongoDB as the persistance layer. I have the following structure: I also have a ResourceRepository: I found online that a way to have the id property returned in the JSON when you perform a GET request like http://localhost:8080/resources/ is to change the id property to Id (uppercase i). Indeed, if the property

Deserializing a list of ints with Spring WebClient

I’m trying to communicate with a Rest service that returns a simple JSON array of ints, e.g. I have the following code to make the call via WebClient: However, Spring returns me an empty Flux. If I replace the bodyToFlux call with a bodyToMono<List<Int>>, then Spring is able to deserialize the response as expected. The drawback being that I have

Advertisement