Код: Выделить всё
org.springframework.web.servlet.NoHandlerFoundException: No endpoint GET /api/utilisateurs/current.
at org.springframework.web.servlet.DispatcherServlet.noHandlerFound(DispatcherServlet.java:1304) ~[spring-webmvc-6.1.4.jar:6.1.4]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-6.1.4.jar:6.1.4]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) ~[spring-webmvc-6.1.4.jar:6.1.4]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) ~[spring-webmvc-6.1.4.jar:6.1.4]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) ~[spring-webmvc-6.1.4.jar:6.1.4]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) ~[tomcat-embed-core-10.1.19.jar:6.0]
Код: Выделить всё
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/utilisateurs")
public class UtilisateurController {
@GetMapping("/current")
@PreAuthorize("isAuthenticated()")
public ResponseEntity getCurrentUser() {
return ResponseEntity.ok(SecurityUtils.getCurrentUtilisateur());
}
}
Код: Выделить всё
@AllArgsConstructor
@Configuration
@EnableWebSecurity
@EnableMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration {
private final ArenaFilter arenaFilter;
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
// Cross-Site Request Forgery disabling
.csrf((csrf) -> csrf
.disable()
)//
.formLogin(Customizer.withDefaults())//
.addFilterBefore(arenaFilter, UsernamePasswordAuthenticationFilter.class)
// Session Management configuration (no creation -> stateless)
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
http
// Request authorization
.authorizeHttpRequests(at -> at.requestMatchers("/actuator/**").permitAll()//
.requestMatchers("/h2-console/**").permitAll()//
.anyRequest().authenticated());
http.headers(h -> h.frameOptions(fr -> fr.sameOrigin()));
http.httpBasic(Customizer.withDefaults());
return http.build();
}
}
Код: Выделить всё
@Log4j2
@Configuration
public class WebConfigurer {
@Bean
public CorsFilter corsFilter(ApplicationProperties applicationProperties) {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = applicationProperties.getCors();
// Si la configuration Cors n'est pas complète, on ne l'applique pas.
if (corsConfiguration.getAllowedOrigins() != null && !corsConfiguration.getAllowedOrigins().isEmpty()) {
log.debug("Enregistrement du filtre CORS");
source.registerCorsConfiguration("/api/**", corsConfiguration);
} else {
log.debug("Pas de configuration CORS fournie");
}
return new CorsFilter(source);
}
@Bean(name = "mvcHandlerMappingIntrospector")
public HandlerMappingIntrospector mvcHandlerMappingIntrospector() {
return new HandlerMappingIntrospector();
}
}
Есть идеи, почему все конечные точки не загружаются при запуске?
Подробнее здесь: https://stackoverflow.com/questions/781 ... -migration
Мобильная версия