4.2. MicroProfile 구성 개발
4.2.1. MicroProfile 구성용 Maven 프로젝트 생성
MicroProfile Config 애플리케이션을 생성하는 데 필요한 종속성과 디렉터리 구조를 사용하여 Maven 프로젝트를 생성합니다.
사전 요구 사항
- Maven이 설치되어 있어야 합니다.
절차
Maven 프로젝트를 설정합니다.
$ mvn archetype:generate \ -DgroupId=com.example \ -DartifactId=microprofile-config \ -DinteractiveMode=false \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DarchetypeArtifactId=maven-archetype-webapp cd microprofile-config
그러면 프로젝트 및
pom.xml
구성 파일에 대한 디렉터리 구조가 생성됩니다.jboss-eap-xp-microprofile
BOM에서 POM 파일이 MicroProfile 구성 아티팩트 및 MicroProfile REST 클라이언트 아티팩트의 버전을 자동으로 관리하도록 하려면 프로젝트 POM 파일의<dependencyManagement>
섹션으로 BOM을 가져옵니다.<dependencyManagement> <dependencies> <!-- importing the microprofile BOM adds MicroProfile specs --> <dependency> <groupId>org.jboss.bom</groupId> <artifactId>jboss-eap-xp-microprofile</artifactId> <version>3.0.0.GA</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
MicroProfile 구성 아티팩트 및 MicroProfile REST 클라이언트 아티팩트 및 BOM에서 관리하는 기타 종속 항목을 프로젝트 POM 파일의
<dependency>
섹션에 추가합니다. 다음 예제에서는 MicroProfile Config 및 MicroProfile REST 클라이언트 종속성을 파일에 추가하는 방법을 보여줍니다.<!-- Add the MicroProfile REST Client API. Set
provided
for the<scope>
tag, as the API is included in the server. --> <dependency> <groupId>org.eclipse.microprofile.rest.client</groupId> <artifactId>microprofile-rest-client-api</artifactId> <scope>provided</scope> </dependency> <!-- Add the MicroProfile Config API. Setprovided
for the<scope>
tag, as the API is included in the server. --> <dependency> <groupId>org.eclipse.microprofile.config</groupId> <artifactId>microprofile-config-api</artifactId> <scope>provided</scope> </dependency> <!-- Add the {JAX-RS} API. Setprovided
for the<scope>
tag, as the API is included in the server. --> <dependency> <groupId>org.jboss.spec.javax.ws.rs</groupId> <artifactId>jboss-jaxrs-api_2.1_spec</artifactId> <scope>provided</scope> </dependency> <!-- Add the CDI API. Setprovided
for the<scope>
tag, as the API is included in the server. --> <dependency> <groupId>jakarta.enterprise</groupId> <artifactId>jakarta.enterprise.cdi-api</artifactId> <scope>provided</scope> </dependency>