Я пытаюсь создать базовую службу отдыха Springboot, которая возвращает "привет", когда вы открываете "/ привет". Я настроил безопасность так, чтобы все запросы были разрешены с помощью .permitAll (), показанного ниже:
WebSecurityConfiguration.java
@EnableWebSecurity
public class WebSecurityConfiguration implements HttpSecurityConfigurer {
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**")
.permitAll();
}
}
У меня также есть класс контроллера с одним указанным путем:
HelloController.java
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String sayHi(){
return "Hi";
}
}
Моя структура проекта выглядит так:
com.test.project.rest.testservice
>TestServiceApplication.java
com.test.project.rest.testservice.config
>WebSecurityConfiguration.java
com.test.project.rest.testservice.controller
>HelloController.java
По какой-то причине все пути просто показывают 404 - не найдено, даже если оно указано вконтроллер или не указано. Что может быть причиной проблемы?
Это зависимости безопасности, которые я использую:
<!-- org.springframework.security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>