inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

Swagger Documentation 구현 - Spring Boot 2.7 사용 ①

swagger거 실행할려고 서버실행시 문제 발생

914

최원호

작성한 질문수 7

0

swaggerConfig

package com.example.restfulness.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@OpenAPIDefinition
public class SwaggerConfig {

    @Bean
    public OpenAPI api() {
        Info info=new Info().title("").version("v3").description("api");
        // Info info=new Info().title().version("v3").description("api");
        // Info info=new Info().title("").version
        return new OpenAPI().components(new Components()).info(info);
    }
}

gradle.build

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.4'
    id 'io.spring.dependency-management' version '1.1.3'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

configurations {
    compileOnly {
       extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    runtimeOnly 'com.h2database:h2'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation 'org.springframework.boot:spring-boot-starter-validation'

    //@XML
    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'

    //@헤테오스
    implementation 'org.springframework.boot:spring-boot-starter-hateoas'
    //implementation 'org.springframework.boot:spring-boot-starter-parent'

    //@스웨거
    implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.4'
    //implementation 'org.springdoc:springdoc-openapi-ui'

}


tasks.named('test') {
    useJUnitPlatform()
}

 

그리고 서버를 재 구동했는데 다음과 같은 메세지가 나타났습니다. 어떻게 해야 할까요?

 

4:23:01 AM: Executing 'dependencies'...

> Task :dependencies

------------------------------------------------------------

Root project 'restfulness'

------------------------------------------------------------

annotationProcessor - Annotation processors and their dependencies for source set 'main'.

\--- org.projectlombok:lombok -> 1.18.30

bootArchives - Configuration for Spring Boot archive artifacts. (n)

No dependencies

compileClasspath - Compile classpath for source set 'main'.

+--- org.projectlombok:lombok -> 1.18.30

+--- org.springframework.boot:spring-boot-starter-data-jpa -> 3.1.4

| +--- org.springframework.boot:spring-boot-starter-aop:3.1.4

| | +--- org.springframework.boot:spring-boot-starter:3.1.4

| | | +--- org.springframework.boot:spring-boot:3.1.4

| | | | +--- org.springframework:spring-core:6.0.12

| | | | | \--- org.springframework:spring-jcl:6.0.12

| | | | \--- org.springframework:spring-context:6.0.12

| | | | +--- org.springframework:spring-aop:6.0.12

| | | | | +--- org.springframework:spring-beans:6.0.12

| | | | | | \--- org.springframework:spring-core:6.0.12 (*)

| | | | | \--- org.springframework:spring-core:6.0.12 (*)

| | | | +--- org.springframework:spring-beans:6.0.12 (*)

| | | | +--- org.springframework:spring-core:6.0.12 (*)

| | | | \--- org.springframework:spring-expression:6.0.12

| | | | \--- org.springframework:spring-core:6.0.12 (*)

| | | +--- org.springframework.boot:spring-boot-autoconfigure:3.1.4

| | | | \--- org.springframework.boot:spring-boot:3.1.4 (*)

| | | +--- org.springframework.boot:spring-boot-starter-logging:3.1.4

| | | | +--- ch.qos.logback:logback-classic:1.4.11

| | | | | +--- ch.qos.logback:logback-core:1.4.11

| | | | | \--- org.slf4j:slf4j-api:2.0.7 -> 2.0.9

| | | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.20.0

| | | | | +--- org.apache.logging.log4j:log4j-api:2.20.0

| | | | | \--- org.slf4j:slf4j-api:1.7.36 -> 2.0.9

| | | | \--- org.slf4j:jul-to-slf4j:2.0.9

| | | | \--- org.slf4j:slf4j-api:2.0.9

| | | +--- jakarta.annotation:jakarta.annotation-api:2.1.1

| | | +--- org.springframework:spring-core:6.0.12 (*)

| | | \--- org.yaml:snakeyaml:1.33

| | +--- org.springframework:spring-aop:6.0.12 (*)

| | \--- org.aspectj:aspectjweaver:1.9.20

| +--- org.springframework.boot:spring-boot-starter-jdbc:3.1.4

| | +--- org.springframework.boot:spring-boot-starter:3.1.4 (*)

| | +--- com.zaxxer:HikariCP:5.0.1

| | | \--- org.slf4j:slf4j-api:1.7.30 -> 2.0.9

| | \--- org.springframework:spring-jdbc:6.0.12

| | +--- org.springframework:spring-beans:6.0.12 (*)

| | +--- org.springframework:spring-core:6.0.12 (*)

| | \--- org.springframework:spring-tx:6.0.12

| | +--- org.springframework:spring-beans:6.0.12 (*)

| | \--- org.springframework:spring-core:6.0.12 (*)

| +--- org.hibernate.orm:hibernate-core:6.2.9.Final

| | +--- jakarta.persistence:jakarta.persistence-api:3.1.0

| | \--- jakarta.transaction:jakarta.transaction-api:2.0.1

| +--- org.springframework.data:spring-data-jpa:3.1.4

| | +--- org.springframework.data:spring-data-commons:3.1.4

| | | +--- org.springframework:spring-core:6.0.12 (*)

| | | +--- org.springframework:spring-beans:6.0.12 (*)

| | | \--- org.slf4j:slf4j-api:2.0.2 -> 2.0.9

| | +--- org.springframework:spring-orm:6.0.12

| | | +--- org.springframework:spring-beans:6.0.12 (*)

| | | +--- org.springframework:spring-core:6.0.12 (*)

| | | +--- org.springframework:spring-jdbc:6.0.12 (*)

| | | \--- org.springframework:spring-tx:6.0.12 (*)

| | +--- org.springframework:spring-context:6.0.12 (*)

| | +--- org.springframework:spring-aop:6.0.12 (*)

| | +--- org.springframework:spring-tx:6.0.12 (*)

| | +--- org.springframework:spring-beans:6.0.12 (*)

| | +--- org.springframework:spring-core:6.0.12 (*)

| | +--- org.antlr:antlr4-runtime:4.10.1

| | +--- jakarta.annotation:jakarta.annotation-api:2.0.0 -> 2.1.1

| | \--- org.slf4j:slf4j-api:2.0.2 -> 2.0.9

| \--- org.springframework:spring-aspects:6.0.12

| \--- org.aspectj:aspectjweaver:1.9.20

+--- org.springframework.boot:spring-boot-starter-web -> 3.1.4

| +--- org.springframework.boot:spring-boot-starter:3.1.4 (*)

| +--- org.springframework.boot:spring-boot-starter-json:3.1.4

| | +--- org.springframework.boot:spring-boot-starter:3.1.4 (*)

| | +--- org.springframework:spring-web:6.0.12

| | | +--- org.springframework:spring-beans:6.0.12 (*)

| | | +--- org.springframework:spring-core:6.0.12 (*)

| | | \--- io.micrometer:micrometer-observation:1.10.11 -> 1.11.4

 

중간생략

No dependencies

(c) - A dependency constraint, not a dependency. The dependency affected by the constraint occurs elsewhere in the tree.

(*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation.

(n) - A dependency or dependency configuration that cannot be resolved.

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 825ms

1 actionable task: 1 executed

4:23:02 AM: Execution finished 'dependencies'.

 

주소창에 localhost:8088/v2/api-docs를 입력했더니 This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Oct 12 04:07:11 KST 2023

There was an unexpected error (type=Not Found, status=404).

No message available

가 보입니다.

 

 

rest-api spring-boot swagger

답변 1

0

인프런 AI 인턴

안녕하세요, 인프런 AI 인턴입니다.

서버 실행 시 문제가 발생하는 것 같습니다. 오류 메시지나 콘솔 출력을 제공해주시면 더 자세한 도움을 드릴 수 있을 것 같습니다. 현재로서는 주어진 코드에서는 오류를 찾을 수 없습니다.

번거로우시겠지만, 서버 실행 시 발생하는 오류 메시지와 해당 문제에 대한 추가적인 설명을 제공해주시면 좀 더 구체적인 도움을 드릴 수 있을 것 같습니다.

감사합니다.

JPA

0

60

1

jpa dependency를 추가하고 SecurityConfig클래스에서 오류가 납니다.

0

70

1

웹 브라우저 400 bad request

0

73

1

@Size는 되는데 @Past는 안 됩니다.

0

62

1

pdf 자료는 없나요?

0

75

2

locale 정보가 null 이면 무조건 messages_ko.properties이 호출 되는 문제

0

90

2

Swagger 강의, Unable to infer base url 이거 뜨시는 분들 도움되시라고

0

120

1

강의에서나온 화면 피피티

0

160

1

HelloWorldBean 관련 에러

0

187

2

Swagger API 3.x 오류..

0

222

1

java: variable message not initialized in the default constructor 에러는 어찌하면 좋을까요?

1

283

1

현재 GIT에 올리신 소스를 실행해봤습니다.

0

189

2

고양이 소리가 귀엽네요 !!

0

139

2

git에서 소스받고 실습중인데

0

119

1

post가 안되요

0

106

1

한국어 같은 경우 언어코드인 messages_ko.properties 로 생성하는게 더 좋지 않나요?

0

169

2

리턴타입으로서 EntityModel<User> 와 ResponseEntity질문

0

106

1

예외처리쪽 관련 질문있습니다.

0

160

2

엔티티가 바로 응답으로 나가도 되나요??

0

224

2

안녕하세여 Cannot invoke "co.kr.joneconsulting.resfulservice.repository.PostRepository.save(Object)" because "this.postRepository" is null

0

140

2

사용자 등록하고 나서 H2 에서 보면 신규 사용자의 password, ssn 이 null 로 되어 있습니다.

0

143

2

ApplictionContext 질문

0

195

2

롬북이 안먹히는것같아요

0

158

1

인텔리제이에서스프링부트 파일 실행하면

0

241

1