Dowon Lee님의 Spring Boot를 이용한 RESTful Web Services 개발 강의를 학습한 내용입니다.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
<!-- <version>2.1.8.RELEASE</version>-->
<version>2.4.3</version>
</dependency>
@GetMapping("/users/{id}")
public EntityModel<User> retrieveUser(@PathVariable int id){
//...
EntityModel<User> model = new EntityModel<>(user);
WebMvcLinkBuilder linkTo = WebMvcLinkBuilder.linkTo(
WebMvcLinkBuilder.methodOn(this.getClass()).retrieveAllUsers());
model.add(linkTo.withRel("all-users"));
return model;
}
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2);
}
}
- localhost:8088/swagger-ui/index.html
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.4.4</version>
</dependency>
management:
endpoints:
web:
exposure:
include: "*"
- localhost:8088/actuator
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
<version>3.3.6.RELEASE</version>
</dependency>
- localhost:8088/browser/index.html
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.1.7.RELEASE</version>
</dependency>
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configGlobal(AuthenticationManagerBuilder auth)
throws Exception{
auth.inMemoryAuthentication()
.withUser("aaaa")
.password("{noop}test1234")
.roles("USER");
}
}