rubytomato / demo-security-jwt-spring2

java 1.8, Spring Security & JWT with Spring Boot 2.0 Rest API application
MIT License
26 stars 7 forks source link

Spring boot 2.2 Error in tests #2

Open nWidart opened 4 years ago

nWidart commented 4 years ago

Hello,

Thank you for providing this boilerplate, very helpful! 👌

I wanted to upgrade to spring boot 2.2.1, and seeing some tests fail:

image

With error message:

Description:

Field userRepository in com.example.demo.security.SecurityConfig required a bean of type 'com.example.demo.repository.UserRepository' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'com.example.demo.repository.UserRepository' in your configuration.

The application does run without issues so I'm not sure why this error message is present, and why only some of the tests. For example, for the UserController and UserRepository there's no error.

Any idea where this could be coming from?

Thanks!

nWidart commented 4 years ago

I might have found a solution, but not sure if it's the proper one:

Adding the following in the failing tests fixed the errors:

@MockBean
private UserRepository userRepository;