sitelink1 | https://www.omnibuscode.com/board/board_dev_bnd/61050 |
---|---|
sitelink2 | |
sitelink3 |
sitelink1 에서 샘플 프로젝트도 다운로드 가능하지만
아주 기본적인 환경만 구성한 샘플 프로젝트 생성을 원한다면 다음과 같은 절차로 생성하면 된다.
1. gradle cli 로 다음과 같이 프로젝트 생성
\ReleaseTest>gradle init
Starting a Gradle Daemon, 1 busy and 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
Select type of build to generate:
1: Application
2: Library
3: Gradle plugin
4: Basic (build structure only)
Enter selection (default: Application) [1..4] 4
Project name (default: ReleaseTest):
Select build script DSL:
1: Kotlin
2: Groovy
Enter selection (default: Kotlin) [1..2] 2
Generate build using new APIs and behavior (some features may change in the next minor release)? (default: no) [yes, no]
> Task :init
Learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.10.2/samples
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.10.2/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 7m 42s
1 actionable task: 1 executed
2. build.gradle 에 다음과 같은 내용을 넣어준다. (내용은 알아서 적당히 수정)
plugins {
id 'java'
id 'war'
id 'eclipse'
id 'eclipse-wtp'
}
group = 'com.mydomain'
version = '1.0.0'
sourceCompatibility = '17'
repositories {
mavenCentral()
}
dependencies {
runtimeOnly 'com.h2database:h2:2.2.224'
implementation 'jakarta.servlet:jakarta.servlet-api:6.0.0'
implementation 'commons-logging:commons-logging:1.2'
implementation 'com.fasterxml.jackson.core:jackson-core:2.17.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
// Selenium 의존성 추가
implementation 'org.seleniumhq.selenium:selenium-java:4.16.1'
implementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.16.1'
}
eclipse {
wtp {
// WTP Component 설정
component {
contextPath = 'example' // context root 설정
deployName = 'example' // 프로젝트의 배포 이름 설정
// Targeted Runtimes 설정
file {
// 서버 이름 추가 (Eclipse에 등록된 서버 이름 사용)
withXml {
def node = it.asNode()
def runtimes = node.appendNode('runtime', [:])
runtimes.appendNode('runtime', ['id': 'Apache Tomcat v10.1'])
}
}
}
// WTP Facet 설정
facet {
facet name: 'jst.web', version: '4.0' // Dynamic Web Module 버전 설정
facet name: 'java', version: '17' // Java 버전 설정
}
}
}
3. 이클립스에서 다음을 설정
- 프로젝트에서 우클릭하여 Properties 진입
- "Project Facets" 선택후 우측 화면에서 "Convert to faceted from..." 링크 클릭
- "Dynamic Web Module", "Java" 체크후 "Runtimes" 탭에서 서버 선택
- 서버를 등록하지 않은 상태라면 이클립스 메인 메뉴에서 "Window>Preferences" 로 창의 띄워 "Server>Runtime Environments"에 서버를 등록한다
- Apply 누르면 Web Project 로 자동 변환
- 프로젝트 Properties 의 "Targeted Runtimes" 로 진입하여 서버를 체크
※ 참고 사항
3번에서 위와 같이 설정한 후에도 프로젝트를 Gradle Refresh 하면 Properties 에 설정한 서버 관련 값들이 초기화 되지만
Gradle 설정에 적용한 환경이 그대로 반영되므로 Tomcat 서버에 Add 하여 실행해도 정상 동작하게 된다.