230103 TIL

William Parker·2023년 1월 3일

Error: LinkageError occurred while loading main class com.user.firstspring.FirstspringApplication java.lang.UnsupportedClassVersionError:

Solve: Looking closely at the error message, it appears that there is a problem with the Java Runtime version. The Java runtime version is as follows, but a problem occurred because the existing version 11 was suddenly changed to version 17.


Error: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com.example.practice.request.SignupRequest (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

Solve: It was solved by reporting @NoArgsConstructor and @AllArgsConstructor to the corresponding SignupRequest model.


Error: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null

Solve: add public InternalResourceViewResolver defaultViewResolver() {
return new InternalResourceViewResolver();} in Security Config.


Problem: How to add Header to Swagger.

Solve: Add in the SwaggerConfig

.securityContexts(Collections.singletonList(securityContext()))
                    .securitySchemes(List.of(apiKey()))
                    
        private SecurityContext securityContext() {
            return SecurityContext.builder()
                    .securityReferences(defaultAuth())
                    .build();
        }

        private List<SecurityReference> defaultAuth() {
            AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
            AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
            authorizationScopes[0] = authorizationScope;
            return List.of(new SecurityReference("Authorization", authorizationScopes));
        }
profile
Developer who does not give up and keeps on going.

0개의 댓글