让我简短地描述一下我现在面临的问题。
\n我已经为 webflux 应用程序配置了 spring security,当我尝试访问不需要身份验证的路由时,我收到登录表单提示。路线是 /swagger-ui/ ,它应该在没有任何登录表单或其他内容的情况下打开。
\n下面是我在 SecurityWebFilterChain 中的代码
\n\n@Bean\npublic SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {\n //@formatter:off\n return http\n .formLogin().disable()\n .httpBasic().disable()\n .authenticationManager(authenticationManager)\n .securityContextRepository(securityContextRepository)\n .authorizeExchange()\n .pathMatchers(HttpMethod.OPTIONS).permitAll()\n .pathMatchers("/v2/api-docs", "/v3/api-docs", "/configuration/ui", "/swagger-resources",\n "/configuration/security", "/swagger-ui/", "/swagge\xe2\x80\x8c\xe2\x80\x8br-ui",\n "/webjars/**", "/swagger-resources/configuration/ui",\n "/swagger-resources/configuration/security").permitAll() // Allowed routes for swagger\n .pathMatchers("/api/auth", "/api/auth/**").permitAll() // Allowed routes for auth\n .and()\n .authorizeExchange()\n .anyExchange()\n .authenticated() // All other routes require authentication\n .and()\n .csrf().disable()\n .headers()\n .hsts()\n .includeSubdomains(true)\n .maxAge(Duration.ofSeconds(31536000))\n .and()\n .frameOptions().mode(XFrameOptionsServerHttpHeadersWriter.Mode.SAMEORIGIN)\n .and()\n .build();\n //@formatter:on\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n如果有人有任何建议,请告诉我,我将不胜感激。这是我在浏览器中得到的图片。
\n\n为所有对象添加 getter 和 setter 方法非常困难,有什么简单的方法可以做到这一点吗?我们可以为此创建一个接口或注释吗?
private String name;
public void setName(String name) {this.name = name;}
public String getName() {return name;}
我希望有类似的东西@GetterSetter private String name;
我知道 Eclipse 和 IDEA 会很容易地生成我想要的东西,我的代码看起来很干净,我不想让我的行数增加 x*5。
我正在使用 Spring Boot 应用程序。
我的控制器中有一个方法可以返回一些资源:
@ResponseBody
@Transactional(rollbackFor = Exception.class)
@GetMapping(value="data/{itemId}/items", produces="application/json")
public Resources<DataExcerpt> listMyData(@PathVariable("debateId") UUID debateId)){
List<DataExcerpt> dataExcerpts = dataService
.listMyData(id)
.stream()
.map(d -> this.projectionFactory.createProjection(DataExcerpt.class, d))
.collect(Collectors.toList());
return new Resources<>(dataExcerpts);
}
Run Code Online (Sandbox Code Playgroud)
这以以下形式返回:
{
"_embedded" : {
"items" : [ {
"position" : {
"name" : "Oui",
"id" : "325cd3b7-1666-4c44-a55f-1e7cc936a3aa",
"color" : "#51B63D",
"usedForPositionType" : "FOR_CON"
},
"id" : "5aa48cfb-5505-43b6-b0a9-5481c895e2bf",
"item" : [ {
"index" : 0,
"id" : "43c2dcd0-6bdb-43b0-be97-2a40b99bc753",
"description" : {
"id" : "021ad7cd-4bf1-4dce-9ea7-10980440a049",
"title" : "Item description",
"modificationCount" …Run Code Online (Sandbox Code Playgroud)