티스토리 뷰

개요

새로 만든 모듈에 spring security starter을 dependencies에 추가하려 하였으나 제대로 작동하지 않음.

 

내용

위와 같이 spring security starte 추가하였으나 아래와 같은 에러가 남

A problem occurred evaluating project ':app-auth'.
> Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter-security] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

 

해결

// gradle Task 의 집합. 작업을 수행하는 작업 단위.
// dependencies 에 추가할 라이브러리들이 정상적으로 동작하는지 테스트하고 apk나 aab 파일로 만드는 등의 작업을 묶어놓은 것.
plugins {
    id 'org.springframework.boot' version '2.7.1'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

//코드 패키지 상의 적용 범위와 어플리케이션 버전, 자바 버전등을 명시.
group = 'com' // Component scan to package
version = '0.0.1-SNAPSHOT' // Application version
sourceCompatibility = '17' // Java version

// 컴파일될때만 오직 동작하는 어노테이션 프로세스
configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

// profile 환경 파일 설정 -능동적 적용할때 사용. 예) spring 'Active profiles' 옵션값을 가져와 빌드 수행.

// BuildScript 는 선언한 플러그인의 의존성을 관리함. 예) spring boot 버전

// 기본적인 주소는 mavenCentral 이지만 폐쇄망일 경우 특정 repo 를 사용해야함.
repositories {
    mavenCentral()
}

//추가적인 라이브러리 선언.
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

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

 

 

회고

해결하긴 했는데 spring web dependencies를 추가했을때와 추가하지 않았을때의 차이가 있었다.

아마 이 부분을 예측하기로는 spring web이 있어야만 security가 돌아가는 구조로 되어있는게 아닌가 싶다.

물론 아닐수도 있어서 계속 찾아봐야 할 것 같다.

더불어 아직 gradle 파일 설정하는 부분 각각의 역활이 명확하지 않아서 이 부분도 계속 찾아봐야 할 것 같다.

 

참고  블로그

https://kotlinworld.com/323

https://velog.io/@iniestar/gradle-tutorial

https://twinparadox.tistory.com/630

https://docs.gradle.org/current/userguide/java_plugin.html

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함