SpringBootサンプルアプリをOpen Libertyで動かす
cafe developer
3 years ago
SpringBootサンプルアプリをOpen Libertyで動かす
SpringBootサンプルアプリのビルド
https://spring.io/guides/gs/spring-boot/
のサンプルアプリを利用する。
$ git clone https://github.com/spring-guides/gs-spring-boot.git
$ cd gs-spring-boot/complete
$ ./mvnw spring-boot:run
pom.xmlにliberty-maven-plugin
を追加。
installAppPackagesにはspring-boot-project
をおまじない。appsDirectoryに指定したapps
ディレクトリー(target/liberty/wlp/usr/servers/defaultServer/apps
)にMavenがビルドしたJarがデプロイされる。
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.3.4</version>
<configuration>
<appsDirectory>apps</appsDirectory>
<installAppPackages>spring-boot-project</installAppPackages>
</configuration>
</plugin>
server.xmlを定義
locationはappsディレクトリーに配置するJarファイル名を指定する。Mavenがthinをやってくれる。
$ vi src/main/liberty/config/server.xml
$ cat src/main/liberty/config/server.xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<featureManager>
<feature>servlet-4.0</feature>
<feature>springBoot-2.0</feature>
</featureManager>
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />
<springBootApplication id="spring-boot-complete"
location="thin-spring-boot-complete-0.0.1-SNAPSHOT.jar"
name="spring-boot-complete" />
</server>
コンテキストルートの変更方法
SpringBoot-1.5の場合
<springBootApplication location="hellospringboot.jar">
<applicationArgument>--server.context-path=/test1</applicationArgument>
</springBootApplication>
SpringBoot-2.0の場合
<springBootApplication location="hellospringboot.jar">
<applicationArgument>--server.servlet.context-path=/test1</applicationArgument>
</springBootApplication>
稼働確認
$ ./mvnw liberty:run
コメント
いいね
投げ銭
最新順
人気順
コメント
いいね
投げ銭
最新順
人気順