본문 바로가기
LENA

SpringBoot 기반 애플리케이션 LENA 배포 시 가이드

탕자·2026년 9월 22일·조회 5

개요


A사의 LENA 도입을 진행 예정이며, 현재 로컬 개발 환경에서 SpringBoot 3.5.2 버전을 사용 중에 있다.

이에 현재 로컬에서 Embedded Tomcat 기반의 SpringBoot 애플리케이션을 WAR로 변환하여 설치형 LENA로 배포할 수 있는 환경을 만들어야 한다.

이를 위해서 아래 2개 작업이 선행되어야 한다.

  • JAR 형태의 자바 실행 환경을 WAR로 Export하여 LENA WAS에 배포

  • SpringBoot Hikari풀(내장 방식)의 DB 연결을 LENA 데이터소스 방식으로 변경

가이드


서버 및 솔루션 버전 정보

  • OS: Windows 11

  • Java: OpenJDK 21

  • LENA 1.3.4.7 (EN10) Tomcat 10.1.55 Based

  • SpringBoot 3.5.2

  • DBMS SQL Server 2025

  • jdbc driver(mssql-jdbc-13.4.0.jre11.jar)

  • Embedded Tomcat Port: 8080

  • LENA WAS Port: 10000

SpringBoot(Embedded Tomcat) + MS SQL Server 2025 + JDK21 구성


1. SpringBoot 디렉토리 구조

db-test-app/
├── pom.xml  ← 이 프로젝트를 빌드할 때 뭐가 필요한지" 적어놓은 설명서
└── src/main/
    ├── java/com/example/dbtest/
    │   ├── DbTestAppApplication.java   ← 메인 실행 클래스
    │   └── controller/DbCheckController.java  ← DB 연결 확인 로직
    └── resources/
        ├── application.yml            ← DB 접속 정보 (공통)
            ├── application-prod.yml            ← 운영 환경용 설정 (커넥션 풀 크게)
            ├── application-dev.yml              ← 개발 환경용 설정 (커넥션 풀 작게)
        └── templates/
            ├── index.html
            └── db-check.html

app.yml

1. Spring Boot는 application.yml(공통)을 먼저 읽고
2. spring.profiles.active 값에 해당하는 application-{프로필명}.yml을 추가로 읽어서 덮어씁니다

※ mvn spring-boot:run -Dspring-boot.run.profiles=dev → mvn 실행 예시

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.5.2</version>
        <relativePath/>
    </parent>

    <groupId>com.example</groupId>
    <artifactId>db-test-app</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>db-test-app</name>
    <description>DB connection test application (embedded Tomcat)</description>

    <properties>
        <java.version>21</java.version>
    </properties>

    <dependencies>
        <!-- 웹 + 내장 톰캣 (기본 포함) -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- JDBC 및 커넥션 풀(HikariCP 기본 포함) -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <!-- 간단한 HTML 페이지 렌더링용 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!-- ============================================ -->
        <!-- DB 드라이버: 사용하는 DB에 맞게 아래 중 하나의 주석을 해제하세요 -->
        <!-- ============================================ -->

        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>13.4.0.jre11</version>
            <scope>runtime</scope>
        </dependency>

        <!-- MySQL 사용 시 -->
        <!--
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        -->

        <!-- PostgreSQL 사용 시 -->
        <!--
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        -->

        <!-- Oracle 사용 시 (버전은 DB 버전에 맞게 조정) -->
        <!--
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc11</artifactId>
            <version>23.4.0.24.05</version>
        </dependency>
        -->

        <!-- MariaDB 사용 시 -->
        <!--
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
        </dependency>
        -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>   → mvn spring-boot:run 명령이 동작하게 해주는 플러그인
            </plugin>
        </plugins>
    </build>

</project>
application.yml (공통)
------------------------
server:
  port: 8080

spring:
  application:
    name: db-test-app

  # 기본 활성 프로필 (없으면 dev로 동작)
  profiles:
    active: dev

  # ================================================
  # ▼▼▼ 여기에 DB 접속 정보를 입력하세요 ▼▼▼
  # ================================================
  datasource:
    url: jdbc:sqlserver://54.180.167.195:1433;databaseName=msdb;encrypt=true;trustServerCertificate=true
    username: sa
    password: '!Admin1234'
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver     # 예: PostgreSQL이면 org.postgresql.Driver

    hikari:
      maximum-pool-size: 5
      minimum-idle: 1
      connection-timeout: 5000

# 콘솔에 SQL 쿼리 로그 보고 싶으면 아래 주석 해제
#  jpa:
#    show-sql: true

logging:
  level:
    com.zaxxer.hikari: INFO




application-prod.yml (운영)
------------------------
spring:
  datasource:
    hikari:
      maximum-pool-size: 20
      minimum-idle: 5
      connection-timeout: 3000
      idle-timeout: 300000
      max-lifetime: 1800000

logging:
  level:
    com.zaxxer.hikari: WARN


application-dev.yml (개발)
------------------------
spring:
  datasource:
    hikari:
      maximum-pool-size: 3
      minimum-idle: 1
      connection-timeout: 5000
      idle-timeout: 60000

logging:
  level:
    com.zaxxer.hikari: DEBUG

3. App Source

package com.example.dbtest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.sql.DatabaseMetaData;

@Controller
public class DbCheckController {

    private final JdbcTemplate jdbcTemplate;

    @Autowired
    public DbCheckController(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @GetMapping("/")
    public String index() {
        return "index";
    }

    @GetMapping("/db-check")
    public String checkDbConnection(Model model) {
        try {
            // JDBC 메타데이터로 기본 정보 확인
            jdbcTemplate.execute((java.sql.Connection conn) -> {
                DatabaseMetaData meta = conn.getMetaData();
                model.addAttribute("dbProductName", meta.getDatabaseProductName());
                model.addAttribute("dbProductVersion", meta.getDatabaseProductVersion());
                model.addAttribute("driverName", meta.getDriverName());
                model.addAttribute("url", meta.getURL());
                return null;
            });

            // SQL Server의 실제 제품명(예: SQL Server 2025)까지 보고 싶으면 @@VERSION 쿼리 사용
            String fullVersion = jdbcTemplate.queryForObject("SELECT @@VERSION", String.class);
            model.addAttribute("fullVersion", fullVersion);

            model.addAttribute("success", true);
            model.addAttribute("message", "DB 연결 성공!");
        } catch (Exception e) {
            model.addAttribute("success", false);
            model.addAttribute("message", "DB 연결 실패: " + e.getMessage());
        }

        return "db-check";
    }
}
package com.example.dbtest;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DbTestAppApplication {

    public static void main(String[] args) {
        SpringApplication.run(DbTestAppApplication.class, args);
    }

}
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DB 연결 확인 결과</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
            background-color: #f4f6f8;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .card {
            background: #ffffff;
            border-radius: 12px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
            padding: 40px;
            width: 600px;
            max-width: 90vw;
            text-align: center;
        }

        h1 {
            font-size: 22px;
            margin-bottom: 24px;
            white-space: nowrap;
        }

        .success { color: #2e7d32; }
        .fail { color: #c62828; }

        table {
            width: 100%;
            border-collapse: collapse;
            table-layout: fixed;
            margin: 0 auto 24px auto;
        }

        th, td {
            border: 1px solid #e0e0e0;
            padding: 12px 14px;
            text-align: left;
            font-size: 14px;
            vertical-align: top;
        }

        th {
            width: 100px;
            white-space: nowrap;
            background-color: #fafafa;
            color: #555;
            font-weight: 600;
        }

        td {
            color: #222;
            word-break: break-all;
            overflow-wrap: anywhere;
        }

        a.button {
            display: inline-block;
            margin-top: 8px;
            padding: 10px 24px;
            background-color: #424242;
            color: #ffffff;
            text-decoration: none;
            border-radius: 6px;
            font-size: 14px;
        }

        a.button:hover {
            background-color: #212121;
        }
    </style>
</head>
<body>
<div class="card">
    <h1 th:class="${success} ? 'success' : 'fail'" th:text="${message}"></h1>

    <table th:if="${success}">
        <tr>
            <th>DB 종류</th>
            <td th:text="${dbProductName}"></td>
        </tr>
        <tr>
            <th>DB 버전</th>
            <td th:text="${dbProductVersion}"></td>
        </tr>
        <tr>
            <th>제품 정보</th>
            <td th:text="${fullVersion}"></td>
        </tr>
        <tr>
            <th>드라이버</th>
            <td th:text="${driverName}"></td>
        </tr>
        <tr>
            <th>접속 URL</th>
            <td th:text="${url}"></td>
        </tr>
    </table>

    <a class="button" href="/">돌아가기</a>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DB 테스트 애플리케이션</title>
    <style>
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body {
            font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
            background-color: #f4f6f8;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .card {
            background: #ffffff;
            border-radius: 12px;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
            padding: 48px 40px;
            width: 480px;
            max-width: 90vw;
            text-align: center;
        }
        h1 { font-size: 22px; margin-bottom: 12px; }
        p { color: #666; font-size: 14px; margin-bottom: 24px; }
        a.button {
            display: inline-block;
            padding: 12px 28px;
            background-color: #2e7d32;
            color: #ffffff;
            text-decoration: none;
            border-radius: 6px;
            font-size: 14px;
        }
        a.button:hover { background-color: #1b5e20; }
    </style>
</head>
<body>
<div class="card">
    <h1>Spring Boot DB 연결 테스트</h1>
    <p>내장 톰캣으로 실행 중인 테스트 애플리케이션입니다.</p>
    <a class="button" href="/db-check">DB 연결 확인하기</a>
</div>
</body>
</html>

2. SpringBoot 실행 및 웹 브라우저 호출

mvn run (실행)

  • 우측 mvn 아이콘 선택 > 상단 메뉴에서 Maven Goal 실행 > mvn spring-boot:run > ENTER

C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2025.2.1\plugins\maven\lib\maven3\bin\mvn.cmd -Didea.version=2025.2.1 -Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2025.2.1\plugins\maven\lib\maven-event-listener.jar -Djansi.passthrough=true -Dstyle.color=always -Dmaven.repo.local=C:\Users\84562\.m2\repository spring-boot:run -f pom.xml
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.example:db-test-app >-----------------------
[INFO] Building db-test-app 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> spring-boot:3.5.2:run (default-cli) > test-compile @ db-test-app >>>
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ db-test-app ---
[INFO] Copying 1 resource from src\main\resources to target\classes
[INFO] Copying 2 resources from src\main\resources to target\classes
[INFO] 
[INFO] --- compiler:3.14.0:compile (default-compile) @ db-test-app ---
[INFO] Nothing to compile - all classes are up to date.
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ db-test-app ---
[INFO] skip non existing resourceDirectory C:\Users\84562\Downloads\db-test-app\db-test-app\src\test\resources
[INFO] 
[INFO] --- compiler:3.14.0:testCompile (default-testCompile) @ db-test-app ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< spring-boot:3.5.2:run (default-cli) < test-compile @ db-test-app <<<
[INFO] 
[INFO] 
[INFO] --- spring-boot:3.5.2:run (default-cli) @ db-test-app ---
[INFO] Attaching agents: []

  .   ____          _            __ _
 /\\ /
__'_ __ _ ()_ __   \ \ \ \
( ( )\
| '_ | '_| | '_ \/ ` | \ \ \ \
 \\/  
__)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.5.2)

2026-08-08T21:36:27.620+09:00  INFO 8676 --- [db-test-app] [           main] c.example.dbtest.DbTestAppApplication    : Starting DbTestAppApplication using Java 21 with PID 8676 (C:\Users\84562\Downloads\db-test-app\db-test-app\target\classes started by 84562 in C:\Users\84562\Downloads\db-test-app\db-test-app)
2026-08-08T21:36:27.623+09:00  INFO 8676 --- [db-test-app] [           main] c.example.dbtest.DbTestAppApplication    : No active profile set, falling back to 1 default profile: "default"
2026-08-08T21:36:28.486+09:00  INFO 8676 --- [db-test-app] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2026-08-08T21:36:28.503+09:00  INFO 8676 --- [db-test-app] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2026-08-08T21:36:28.503+09:00  INFO 8676 --- [db-test-app] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.42]
2026-08-08T21:36:28.565+09:00  INFO 8676 --- [db-test-app] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2026-08-08T21:36:28.566+09:00  INFO 8676 --- [db-test-app] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 898 ms
2026-08-08T21:36:28.773+09:00  INFO 8676 --- [db-test-app] [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page template: index
2026-08-08T21:36:29.055+09:00  INFO 8676 --- [db-test-app] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '/'
2026-08-08T21:36:29.061+09:00  INFO 8676 --- [db-test-app] [           main] c.example.dbtest.DbTestAppApplication    : Started DbTestAppApplication in 1.916 seconds (process running for 2.312)
2026-08-08T21:36:33.997+09:00  INFO 8676 --- [db-test-app] [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2026-08-08T21:36:34.000+09:00  INFO 8676 --- [db-test-app] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2026-08-08T21:36:34.001+09:00  INFO 8676 --- [db-test-app] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2026-08-08T21:36:34.038+09:00  INFO 8676 --- [db-test-app] [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2026-08-08T21:36:34.509+09:00  INFO 8676 --- [db-test-app] [nio-8080-exec-1] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection ConnectionID:1 ClientConnectionId: c6ffa939-f7fe-4e1c-81b5-b0d940943c8c
2026-08-08T21:36:34.510+09:00  INFO 8676 --- [db-test-app] [nio-8080-exec-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.

웹 브라우저 호출하여 정상 서비스 확인

Export WAR + LENA + HikariCP 사용 시 가이드


사전 준비 사항

  • Windows 환경, LENA 1.3.4.7 설치

  • MS SQL Server 2025 구성  

1. pom.xml 수정

1.1. packaging 추가

<groupId>com.example</groupId>
<artifactId>db-test-app</artifactId>
<packaging>war</packaging> ← 추가

1.2. spring-boot-starter-web 밑에 Tomcat 의존성 추가

       <!-- WAR로 배포 시 외부 WAS의 서블릿 컨테이너를 쓰도록 함
             (내장 톰캣은 빌드에만 포함되고 실제 배포에는 제외됨) -->

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

2. ServletInitializer.java 파일 추가

Spring Boot를 WAR로 배포하려면, 외부 WAS가 애플리케이션을 어떻게 실행시킬지 알려주는 클래스가 하나 필요합니다.

※ 소스 경로: src/main/java/com/example/dbtest/ServletInitializer.java

package com.example.dbtest;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DbTestAppApplication.class);
    }

}

3. mvn clean & package

mvn package (WAR 패키징)

  • 우측 mvn 아이콘 선택 > 라이프사이클 > package 버튼 클릭하여 target 경로에 WAR 파일 생성

C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2025.2.1\plugins\maven\lib\maven3\bin\mvn.cmd -Didea.version=2025.2.1 -Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2025.2.1\plugins\maven\lib\maven-event-listener.jar -Djansi.passthrough=true -Dstyle.color=always -Dmaven.repo.local=C:\Users\84562\.m2\repository package -f pom.xml
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.example:db-test-app >-----------------------
[INFO] Building db-test-app 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ db-test-app ---
[INFO] Copying 3 resources from src\main\resources to target\classes
[INFO] Copying 2 resources from src\main\resources to target\classes
[INFO] 
[INFO] --- compiler:3.14.0:compile (default-compile) @ db-test-app ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 3 source files with javac [debug parameters release 21] to target\classes
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ db-test-app ---
[INFO] skip non existing resourceDirectory C:\Users\84562\Downloads\db-test-app\db-test-app\src\test\resources
[INFO] 
[INFO] --- compiler:3.14.0:testCompile (default-testCompile) @ db-test-app ---
[INFO] No sources to compile
[INFO] 
[INFO] --- surefire:3.5.3:test (default-test) @ db-test-app ---
[INFO] No tests to run.
[INFO] 
[INFO] --- war:3.4.0:war (default-war) @ db-test-app ---
[INFO] Packaging webapp
[INFO] Assembling webapp [db-test-app] in [C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT]
[INFO] Processing war project
[INFO] Building war: C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT.war
[INFO] 
[INFO] --- spring-boot:3.5.2:repackage (repackage) @ db-test-app ---
[INFO] Replacing main artifact C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT.war with repackaged archive, adding nested dependencies in BOOT-INF/.
[INFO] The original artifact has been renamed to C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT.war.original
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.302 s
[INFO] Finished at: 2026-08-08T22:24:03+09:00
[INFO] ------------------------------------------------------------------------

4. LENA APP 배포 및 서비스 호출

  • Manager > Resource > ROOT.war 애플리케이션 배포

  • 서비스 호출하여 정상 서비스 확인

5. 진단 > 데이터소스 모니터링

  • spring.active.profile 설정 없을 경우 (dev가 default)

    • 데이터소스 커넥션 풀이 개발기 설정에 맞게 세팅

  • spring.active.profile=prod 설정 시

    • 데이터소스 커넥션 풀이 운영기 설정에 맞게 세팅

Export WAR + LENA Datasource 사용 시 가이드


사전 준비 사항

  • Windows 환경, LENA 1.3.4.7 설치

  • MS SQL Server 2025 구성  

1. pom.xml 수정

1.1. packaging 추가

<groupId>com.example</groupId>
<artifactId>db-test-app</artifactId>
<packaging>war</packaging> ← 추가

1.2. spring-boot-starter-web 밑에 Tomcat 의존성 추가

       <!-- WAR로 배포 시 외부 WAS의 서블릿 컨테이너를 쓰도록 함
             (내장 톰캣은 빌드에만 포함되고 실제 배포에는 제외됨) -->

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

2. ServletInitializer.java 파일 추가

Spring Boot를 WAR로 배포하려면, 외부 WAS가 애플리케이션을 어떻게 실행시킬지 알려주는 클래스가 하나 필요합니다.

※ 소스 경로: src/main/java/com/example/dbtest/ServletInitializer.java

package com.example.dbtest;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(DbTestAppApplication.class);
    }

}

3. application.yml 파일 수정

application.yml (공통)
# DB 연결 정보와 HikariCP 관련 설정이 모두 제거 됨.
------------------------
server:
  port: 8080

spring:
  application:
    name: db-test-app

  profiles:
    active: dev


application-prod.yml (운영)
# spring.datasource.jndi-name을 통해 외부 WAS의 JNDI에 등록된 데이터소스와 연결한다.
------------------------
spring:
  datasource:
    jndi-name: java:comp/env/jdbc/test
# Hikari가 커넥션 풀을 만드는 게 아니라, **LENA의 server.xml/context.xml에 정의된 DataSource를 JNDI로 조회(lookup)**해서 사용함. 
# Spring Boot는 spring.datasource.jndi-name 속성만 있으면 자동으로 Hikari 대신 JNDI 조회를 사용함.

4. LENA 데이터소스 등록

  • JNDI Name: jdbc/test 

5. mvn clean & package

mvn clean

[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.example:db-test-app >-----------------------
[INFO] Building db-test-app 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- clean:3.4.1:clean (default-clean) @ db-test-app ---
[INFO] Deleting C:\Users\84562\Downloads\db-test-app\db-test-app\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.975 s
[INFO] Finished at: 2026-08-09T21:17:07+09:00
[INFO] ------------------------------------------------------------------------

mvn package (WAR 패키징)

  • 우측 mvn 아이콘 선택 > 라이프사이클 > package 버튼 클릭하여 target 경로에 WAR 파일 생성

[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.example:db-test-app >-----------------------
[INFO] Building db-test-app 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ db-test-app ---
[INFO] Copying 3 resources from src\main\resources to target\classes
[INFO] Copying 2 resources from src\main\resources to target\classes
[INFO] 
[INFO] --- compiler:3.14.0:compile (default-compile) @ db-test-app ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 3 source files with javac [debug parameters release 21] to target\classes
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ db-test-app ---
[INFO] skip non existing resourceDirectory C:\Users\84562\Downloads\db-test-app\db-test-app\src\test\resources
[INFO] 
[INFO] --- compiler:3.14.0:testCompile (default-testCompile) @ db-test-app ---
[INFO] No sources to compile
[INFO] 
[INFO] --- surefire:3.5.3:test (default-test) @ db-test-app ---
[INFO] No tests to run.
[INFO] 
[INFO] --- war:3.4.0:war (default-war) @ db-test-app ---
[INFO] Packaging webapp
[INFO] Assembling webapp [db-test-app] in [C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT]
[INFO] Processing war project
[INFO] Building war: C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT.war
[INFO] 
[INFO] --- spring-boot:3.5.2:repackage (repackage) @ db-test-app ---
[INFO] Replacing main artifact C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT.war with repackaged archive, adding nested dependencies in BOOT-INF/.
[INFO] The original artifact has been renamed to C:\Users\84562\Downloads\db-test-app\db-test-app\target\ROOT.war.original
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.441 s
[INFO] Finished at: 2026-08-09T21:21:40+09:00
[INFO] ------------------------------------------------------------------------

6. LENA APP 배포 및 서비스 호출

  • Manager > Resource > ROOT.war 애플리케이션 배포

  • LENA CATALINA_OPTS 설정

    • spring.active.profile=prod 설정

  • 웹 브라우저 호출하여 정상 서비스 확인

7. 진단 > 데이터소스 모니터링

  • LENA 데이터소스 사용 시, HikariCP 모니터링 데이터가 보이지 않으며 LENA 데이터소스를 사용하는 것을 확인

관련 글

댓글 0

로그인 후 댓글을 남길 수 있습니다.

아직 댓글이 없습니다.