• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

spring security

21.06.12 17:37 작성 조회수 263

0

java.lang.NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.of([Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/PluginRegistry;

pom.xml에 시큐리티만 추가했을뿐인데 저렇게 에러가 터지네요 

현재 스프링부틑 2.4x를 사용중입니다.  

스웨거는최신 3.0사용중입니다. 

답변 1

답변을 작성해보세요.

0

안녕하세요, 이도원입니다. 

Spring Boot와 Swagger의 버전에 의해 종속성 문제인 것 같습니다. pom.xml 파일에서 관련 dependency를 다음과 같이 변경하시고, Controller 클래스의 코드를 아래와 같이 수정해 보시기 바랍니다. 

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<!-- <version>2.1.8.RELEASE</version>-->
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
<version>3.3.6.RELEASE</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<!-- <artifactId>springfox-swagger2</artifactId>-->
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<!-- <version>2.9.2</version>-->
<version>3.0.0</version>
</dependency>

#UserController.java

// @GetMapping("/users2")
// public Resources<Resource<User>> retrieveUserList() {
// List<Resource<User>> result = new ArrayList<>();
// List<User> users = service.findAll();
//
// for (User user : users) {
// Resource<User> resource = new Resource<>(user);
// ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllUsers());
// resource.add(linkTo.withRel("all-users"));
//
// result.add(resource);
// }
//
// return new Resources(result);
// }

// 전체 사용자 목록
@GetMapping("/users2")
public ResponseEntity<CollectionModel<EntityModel<User>>> retrieveUserList2() {
List<EntityModel<User>> result = new ArrayList<>();
List<User> users = service.findAll();

for (User user : users) {
EntityModel entityModel = EntityModel.of(user);
entityModel.add(linkTo(methodOn(this.getClass()).retrieveAllUsers()).withSelfRel());

result.add(entityModel);
}

return ResponseEntity.ok(CollectionModel.of(result, linkTo(methodOn(this.getClass()).retrieveAllUsers()).withSelfRel()));
}

감사합니다.