JAVA-13855 Create new microservices-modules (#12612)

This commit is contained in:
anuragkumawat 2022-08-20 14:20:24 +05:30 committed by GitHub
parent 14c998c3ac
commit 6bc1d484ca
95 changed files with 661 additions and 639 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0" version="2.0"
bean-discovery-mode="annotated"> bean-discovery-mode="annotated">
</beans> </beans>

View File

@ -1,29 +1,29 @@
package com.baeldung.helidon.se.config; package com.baeldung.helidon.se.config;
import io.helidon.config.Config; import io.helidon.config.Config;
import io.helidon.config.ConfigSources; import io.helidon.config.ConfigSources;
import io.helidon.config.spi.ConfigSource; import io.helidon.config.spi.ConfigSource;
public class ConfigApplication { public class ConfigApplication {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
ConfigSource configSource = ConfigSources.classpath("application.yaml").build(); ConfigSource configSource = ConfigSources.classpath("application.yaml").build();
Config config = Config.builder() Config config = Config.builder()
.disableSystemPropertiesSource() .disableSystemPropertiesSource()
.disableEnvironmentVariablesSource() .disableEnvironmentVariablesSource()
.sources(configSource) .sources(configSource)
.build(); .build();
int port = config.get("server.port").asInt(); int port = config.get("server.port").asInt();
int pageSize = config.get("web.page-size").asInt(); int pageSize = config.get("web.page-size").asInt();
boolean debug = config.get("web.debug").asBoolean(); boolean debug = config.get("web.debug").asBoolean();
String userHome = config.get("user.home").asString(); String userHome = config.get("user.home").asString();
System.out.println("port: " + port); System.out.println("port: " + port);
System.out.println("pageSize: " + pageSize); System.out.println("pageSize: " + pageSize);
System.out.println("debug: " + debug); System.out.println("debug: " + debug);
System.out.println("userHome: " + userHome); System.out.println("userHome: " + userHome);
} }
} }

View File

@ -1,49 +1,49 @@
package com.baeldung.helidon.se.routing; package com.baeldung.helidon.se.routing;
public class Book { public class Book {
private String id; private String id;
private String isbn; private String isbn;
private String name; private String name;
private String author; private String author;
private Integer pages; private Integer pages;
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public String getIsbn() { public String getIsbn() {
return isbn; return isbn;
} }
public void setIsbn(String isbn) { public void setIsbn(String isbn) {
this.isbn = isbn; this.isbn = isbn;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getAuthor() { public String getAuthor() {
return author; return author;
} }
public void setAuthor(String author) { public void setAuthor(String author) {
this.author = author; this.author = author;
} }
public Integer getPages() { public Integer getPages() {
return pages; return pages;
} }
public void setPages(Integer pages) { public void setPages(Integer pages) {
this.pages = pages; this.pages = pages;
} }
} }

View File

@ -1,49 +1,49 @@
package com.baeldung.helidon.se.routing; package com.baeldung.helidon.se.routing;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class BookManager { public class BookManager {
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM"); private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
private AtomicInteger bookIdGenerator = new AtomicInteger(0); private AtomicInteger bookIdGenerator = new AtomicInteger(0);
private ConcurrentMap<String, Book> inMemoryStore = new ConcurrentHashMap<>(); private ConcurrentMap<String, Book> inMemoryStore = new ConcurrentHashMap<>();
public BookManager() { public BookManager() {
Book book = new Book(); Book book = new Book();
book.setId(getNextId()); book.setId(getNextId());
book.setName("Building Microservice With Oracle Helidon"); book.setName("Building Microservice With Oracle Helidon");
book.setIsbn("11223344"); book.setIsbn("11223344");
book.setAuthor("baeldung"); book.setAuthor("baeldung");
book.setPages(560); book.setPages(560);
inMemoryStore.put(book.getId(), book); inMemoryStore.put(book.getId(), book);
} }
private String getNextId() { private String getNextId() {
String date = LocalDate.now().format(formatter); String date = LocalDate.now().format(formatter);
return String.format("%04d-%s", bookIdGenerator.incrementAndGet(), date); return String.format("%04d-%s", bookIdGenerator.incrementAndGet(), date);
} }
public String add(Book book) { public String add(Book book) {
String id = getNextId(); String id = getNextId();
book.setId(id); book.setId(id);
inMemoryStore.put(id, book); inMemoryStore.put(id, book);
return id; return id;
} }
public Book get(String id) { public Book get(String id) {
return inMemoryStore.get(id); return inMemoryStore.get(id);
} }
public List<Book> getAll() { public List<Book> getAll() {
List<Book> books = new ArrayList<>(); List<Book> books = new ArrayList<>();
books.addAll(inMemoryStore.values()); books.addAll(inMemoryStore.values());
return books; return books;
} }
} }

View File

@ -1,58 +1,58 @@
package com.baeldung.helidon.se.routing; package com.baeldung.helidon.se.routing;
import io.helidon.webserver.Routing; import io.helidon.webserver.Routing;
import io.helidon.webserver.ServerRequest; import io.helidon.webserver.ServerRequest;
import io.helidon.webserver.ServerResponse; import io.helidon.webserver.ServerResponse;
import io.helidon.webserver.Service; import io.helidon.webserver.Service;
import javax.json.Json; import javax.json.Json;
import javax.json.JsonArray; import javax.json.JsonArray;
import javax.json.JsonArrayBuilder; import javax.json.JsonArrayBuilder;
import javax.json.JsonObject; import javax.json.JsonObject;
import java.util.List; import java.util.List;
public class BookResource implements Service { public class BookResource implements Service {
private BookManager bookManager = new BookManager(); private BookManager bookManager = new BookManager();
@Override @Override
public void update(Routing.Rules rules) { public void update(Routing.Rules rules) {
rules rules
.get("/", this::books) .get("/", this::books)
.get("/{id}", this::bookById); .get("/{id}", this::bookById);
} }
private void bookById(ServerRequest serverRequest, ServerResponse serverResponse) { private void bookById(ServerRequest serverRequest, ServerResponse serverResponse) {
//get the book with the given id //get the book with the given id
String id = serverRequest.path().param("id"); String id = serverRequest.path().param("id");
Book book = bookManager.get(id); Book book = bookManager.get(id);
JsonObject jsonObject = from(book); JsonObject jsonObject = from(book);
serverResponse.send(jsonObject); serverResponse.send(jsonObject);
} }
private void books(ServerRequest serverRequest, ServerResponse serverResponse) { private void books(ServerRequest serverRequest, ServerResponse serverResponse) {
//get all books //get all books
List<Book> books = bookManager.getAll(); List<Book> books = bookManager.getAll();
JsonArray jsonArray = from(books); JsonArray jsonArray = from(books);
serverResponse.send(jsonArray); serverResponse.send(jsonArray);
} }
private JsonObject from(Book book) { private JsonObject from(Book book) {
JsonObject jsonObject = Json.createObjectBuilder() JsonObject jsonObject = Json.createObjectBuilder()
.add("id", book.getId()) .add("id", book.getId())
.add("isbn", book.getIsbn()) .add("isbn", book.getIsbn())
.add("name", book.getName()) .add("name", book.getName())
.add("author", book.getAuthor()) .add("author", book.getAuthor())
.add("pages", book.getPages()) .add("pages", book.getPages())
.build(); .build();
return jsonObject; return jsonObject;
} }
private JsonArray from(List<Book> books) { private JsonArray from(List<Book> books) {
JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder(); JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder();
books.forEach(book -> { books.forEach(book -> {
jsonArrayBuilder.add(from(book)); jsonArrayBuilder.add(from(book));
}); });
return jsonArrayBuilder.build(); return jsonArrayBuilder.build();
} }
} }

View File

@ -1,29 +1,29 @@
package com.baeldung.helidon.se.routing; package com.baeldung.helidon.se.routing;
import io.helidon.webserver.Routing; import io.helidon.webserver.Routing;
import io.helidon.webserver.ServerConfiguration; import io.helidon.webserver.ServerConfiguration;
import io.helidon.webserver.WebServer; import io.helidon.webserver.WebServer;
import io.helidon.webserver.json.JsonSupport; import io.helidon.webserver.json.JsonSupport;
public class WebApplicationRouting { public class WebApplicationRouting {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
ServerConfiguration serverConfig = ServerConfiguration.builder() ServerConfiguration serverConfig = ServerConfiguration.builder()
.port(9080) .port(9080)
.build(); .build();
Routing routing = Routing.builder() Routing routing = Routing.builder()
.register(JsonSupport.get()) .register(JsonSupport.get())
.register("/books", new BookResource()) .register("/books", new BookResource())
.get("/greet", (request, response) -> response.send("Hello World !")) .get("/greet", (request, response) -> response.send("Hello World !"))
.build(); .build();
WebServer.create(serverConfig, routing) WebServer.create(serverConfig, routing)
.start() .start()
.thenAccept(ws -> .thenAccept(ws ->
System.out.println("Server started at: http://localhost:" + ws.port()) System.out.println("Server started at: http://localhost:" + ws.port())
); );
} }
} }

View File

@ -1,33 +1,33 @@
package com.baeldung.helidon.se.security; package com.baeldung.helidon.se.security;
import io.helidon.security.provider.httpauth.UserStore; import io.helidon.security.provider.httpauth.UserStore;
import java.util.Collection; import java.util.Collection;
public class MyUser implements UserStore.User { public class MyUser implements UserStore.User {
private String login; private String login;
private char[] password; private char[] password;
private Collection<String> roles; private Collection<String> roles;
public MyUser(String login, char[] password, Collection<String> roles) { public MyUser(String login, char[] password, Collection<String> roles) {
this.login = login; this.login = login;
this.password = password; this.password = password;
this.roles = roles; this.roles = roles;
} }
@Override @Override
public String getLogin() { public String getLogin() {
return login; return login;
} }
@Override @Override
public char[] getPassword() { public char[] getPassword() {
return password; return password;
} }
@Override @Override
public Collection<String> getRoles() { public Collection<String> getRoles() {
return roles; return roles;
} }
} }

View File

@ -1,61 +1,61 @@
package com.baeldung.helidon.se.security; package com.baeldung.helidon.se.security;
import io.helidon.config.Config; import io.helidon.config.Config;
import io.helidon.security.Security; import io.helidon.security.Security;
import io.helidon.security.SubjectType; import io.helidon.security.SubjectType;
import io.helidon.security.provider.httpauth.HttpBasicAuthProvider; import io.helidon.security.provider.httpauth.HttpBasicAuthProvider;
import io.helidon.security.provider.httpauth.UserStore; import io.helidon.security.provider.httpauth.UserStore;
import io.helidon.security.webserver.WebSecurity; import io.helidon.security.webserver.WebSecurity;
import io.helidon.webserver.Routing; import io.helidon.webserver.Routing;
import io.helidon.webserver.ServerConfiguration; import io.helidon.webserver.ServerConfiguration;
import io.helidon.webserver.WebServer; import io.helidon.webserver.WebServer;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class WebApplicationSecurity { public class WebApplicationSecurity {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
Config config = Config.create(); Config config = Config.create();
ServerConfiguration serverConfig = ServerConfiguration serverConfig =
ServerConfiguration.fromConfig(config.get("server")); ServerConfiguration.fromConfig(config.get("server"));
Map<String, MyUser> users = new HashMap<>(); Map<String, MyUser> users = new HashMap<>();
users.put("user", new MyUser("user", "user".toCharArray(), Arrays.asList("ROLE_USER"))); users.put("user", new MyUser("user", "user".toCharArray(), Arrays.asList("ROLE_USER")));
users.put("admin", new MyUser("admin", "admin".toCharArray(), Arrays.asList("ROLE_USER", "ROLE_ADMIN"))); users.put("admin", new MyUser("admin", "admin".toCharArray(), Arrays.asList("ROLE_USER", "ROLE_ADMIN")));
UserStore store = user -> Optional.ofNullable(users.get(user)); UserStore store = user -> Optional.ofNullable(users.get(user));
HttpBasicAuthProvider httpBasicAuthProvider = HttpBasicAuthProvider.builder() HttpBasicAuthProvider httpBasicAuthProvider = HttpBasicAuthProvider.builder()
.realm("myRealm") .realm("myRealm")
.subjectType(SubjectType.USER) .subjectType(SubjectType.USER)
.userStore(store) .userStore(store)
.build(); .build();
//1. Using Builder Pattern or Config Pattern //1. Using Builder Pattern or Config Pattern
Security security = Security.builder() Security security = Security.builder()
.addAuthenticationProvider(httpBasicAuthProvider) .addAuthenticationProvider(httpBasicAuthProvider)
.build(); .build();
//Security security = Security.fromConfig(config); //Security security = Security.fromConfig(config);
//2. WebSecurity from Security or from Config //2. WebSecurity from Security or from Config
// WebSecurity webSecurity = WebSecurity.from(security) // WebSecurity webSecurity = WebSecurity.from(security)
// .securityDefaults(WebSecurity.authenticate()); // .securityDefaults(WebSecurity.authenticate());
WebSecurity webSecurity = WebSecurity.from(config); WebSecurity webSecurity = WebSecurity.from(config);
Routing routing = Routing.builder() Routing routing = Routing.builder()
.register(webSecurity) .register(webSecurity)
.get("/user", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_USER")) .get("/user", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_USER"))
.get("/admin", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_ADMIN")) .get("/admin", (request, response) -> response.send("Hello, I'm a Helidon SE user with ROLE_ADMIN"))
.build(); .build();
WebServer webServer = WebServer.create(serverConfig, routing); WebServer webServer = WebServer.create(serverConfig, routing);
webServer.start().thenAccept(ws -> webServer.start().thenAccept(ws ->
System.out.println("Server started at: http://localhost:" + ws.port()) System.out.println("Server started at: http://localhost:" + ws.port())
); );
} }
} }

View File

@ -1,26 +1,26 @@
package com.baeldung.helidon.se.webserver; package com.baeldung.helidon.se.webserver;
import io.helidon.webserver.Routing; import io.helidon.webserver.Routing;
import io.helidon.webserver.ServerConfiguration; import io.helidon.webserver.ServerConfiguration;
import io.helidon.webserver.WebServer; import io.helidon.webserver.WebServer;
public class SimpleWebApplication { public class SimpleWebApplication {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
ServerConfiguration serverConfig = ServerConfiguration.builder() ServerConfiguration serverConfig = ServerConfiguration.builder()
.port(9001) .port(9001)
.build(); .build();
Routing routing = Routing.builder() Routing routing = Routing.builder()
.get("/greet", (request, response) -> response.send("Hello World !")) .get("/greet", (request, response) -> response.send("Hello World !"))
.build(); .build();
WebServer.create(serverConfig, routing) WebServer.create(serverConfig, routing)
.start() .start()
.thenAccept(ws -> .thenAccept(ws ->
System.out.println("Server started at: http://localhost:" + ws.port()) System.out.println("Server started at: http://localhost:" + ws.port())
); );
} }
} }

View File

@ -1,4 +1,4 @@
server.port=9080 server.port=9080
web.debug=true web.debug=true
web.page-size=15 web.page-size=15
user.home=C:/Users/app user.home=C:/Users/app

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId> <artifactId>microservices-modules</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>

0
micronaut/mvnw → microservices-modules/micronaut/mvnw vendored Executable file → Normal file
View File

322
micronaut/mvnw.cmd → microservices-modules/micronaut/mvnw.cmd vendored Executable file → Normal file
View File

@ -1,161 +1,161 @@
@REM ---------------------------------------------------------------------------- @REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one @REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file @REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information @REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file @REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the @REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance @REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at @REM with the License. You may obtain a copy of the License at
@REM @REM
@REM http://www.apache.org/licenses/LICENSE-2.0 @REM http://www.apache.org/licenses/LICENSE-2.0
@REM @REM
@REM Unless required by applicable law or agreed to in writing, @REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an @REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the @REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations @REM specific language governing permissions and limitations
@REM under the License. @REM under the License.
@REM ---------------------------------------------------------------------------- @REM ----------------------------------------------------------------------------
@REM ---------------------------------------------------------------------------- @REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script @REM Maven2 Start Up Batch script
@REM @REM
@REM Required ENV vars: @REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir @REM JAVA_HOME - location of a JDK home dir
@REM @REM
@REM Optional ENV vars @REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir @REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use @REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ---------------------------------------------------------------------------- @REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off @echo off
@REM set title of command window @REM set title of command window
title %0 title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME @REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one @REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending @REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre :skipRcPre
@setlocal @setlocal
set ERROR_CODE=0 set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal @REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal @setlocal
@REM ==== START VALIDATION ==== @REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome if not "%JAVA_HOME%" == "" goto OkJHome
echo. echo.
echo Error: JAVA_HOME not found in your environment. >&2 echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2 echo location of your Java installation. >&2
echo. echo.
goto error goto error
:OkJHome :OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init if exist "%JAVA_HOME%\bin\java.exe" goto init
echo. echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2 echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2 echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2 echo location of your Java installation. >&2
echo. echo.
goto error goto error
@REM ==== END VALIDATION ==== @REM ==== END VALIDATION ====
:init :init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found. @REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD% set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR% set WDIR=%EXEC_DIR%
:findBaseDir :findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd .. cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD% set WDIR=%CD%
goto findBaseDir goto findBaseDir
:baseDirFound :baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR% set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%" cd "%EXEC_DIR%"
goto endDetectBaseDir goto endDetectBaseDir
:baseDirNotFound :baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR% set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%" cd "%EXEC_DIR%"
:endDetectBaseDir :endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion @setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig :endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar" set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.0/maven-wrapper-0.4.0.jar"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
) )
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data. @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% ( if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR% echo Found %WRAPPER_JAR%
) else ( ) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ... echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL% echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR% echo Finished downloading %WRAPPER_JAR%
) )
@REM End of extension @REM End of extension
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error if ERRORLEVEL 1 goto error
goto end goto end
:error :error
set ERROR_CODE=1 set ERROR_CODE=1
:end :end
@endlocal & set ERROR_CODE=%ERROR_CODE% @endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending @REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost :skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE% exit /B %ERROR_CODE%

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId> <artifactId>microservices-modules</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId> <artifactId>microservices-modules</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>

View File

@ -10,7 +10,7 @@
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId> <artifactId>microservices-modules</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>

View File

@ -0,0 +1,127 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>open-liberty</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>microservices-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>${version.jakarta.jakartaee-web-api}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>${version.microprofile}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${version.derby}</version>
<scope>provided</scope>
</dependency>
<!-- For tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>${version.yasson}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>${version.cxf-rt-rs-client}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>${version.javax.json}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-mp-client</artifactId>
<version>${version.cxf-rt-rs-mp-client}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- Enable liberty-maven plugin -->
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>${version.liberty-maven-plugin}</version>
<configuration>
<copyDependencies>
<location>${project.build.directory}/liberty/wlp/usr/shared/resources/</location>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${version.derby}</version>
</dependency>
</copyDependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${version.maven-war-plugin}</version>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- versions -->
<version.jakarta.jakartaee-web-api>8.0.0</version.jakarta.jakartaee-web-api>
<version.microprofile>3.2</version.microprofile>
<version.derby>10.14.2.0</version.derby>
<version.liberty-maven-plugin>3.3-M3</version.liberty-maven-plugin>
<version.maven-war-plugin>3.2.3</version.maven-war-plugin>
<version.yasson>1.0.5</version.yasson>
<version.cxf-rt-rs-client>3.2.6</version.cxf-rt-rs-client>
<version.javax.json>1.0.4</version.javax.json>
<version.cxf-rt-rs-mp-client>3.3.1</version.cxf-rt-rs-mp-client>
<!-- Liberty configuration -->
<liberty.var.app.context.root>openliberty</liberty.var.app.context.root>
<liberty.var.default.http.port>9080</liberty.var.default.http.port>
<liberty.var.default.https.port>9443</liberty.var.default.https.port>
<testServerHttpPort>7070</testServerHttpPort>
<junit-jupiter.version>5.8.1</junit-jupiter.version>
</properties>
</project>

View File

@ -10,7 +10,7 @@ import org.junit.Test;
import com.baeldung.openliberty.person.model.Person; import com.baeldung.openliberty.person.model.Person;
import com.baeldung.openliberty.rest.consumes.RestConsumer; import com.baeldung.openliberty.rest.consumes.RestConsumer;
public class RestClientTest { public class RestClientLiveTest {
private static String BASE_URL; private static String BASE_URL;

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>microservices-modules</artifactId>
<name>microservices-modules</name>
<packaging>pom</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modules>
<module>helidon</module>
<module>micronaut</module>
<module>microprofile</module>
<module>msf4j</module>
<module>open-liberty</module>
</modules>
</project>

View File

@ -1,121 +0,0 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>open-liberty</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>${version.jakarta.jakartaee-web-api}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>${version.microprofile}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${version.derby}</version>
<scope>provided</scope>
</dependency>
<!-- For tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>${version.yasson}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>${version.cxf-rt-rs-client}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>${version.javax.json}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-mp-client</artifactId>
<version>${version.cxf-rt-rs-mp-client}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<!-- Enable liberty-maven plugin -->
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>${version.liberty-maven-plugin}</version>
<configuration>
<copyDependencies>
<location>${project.build.directory}/liberty/wlp/usr/shared/resources/</location>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${version.derby}</version>
</dependency>
</copyDependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${version.maven-war-plugin}</version>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- versions -->
<version.jakarta.jakartaee-web-api>8.0.0</version.jakarta.jakartaee-web-api>
<version.microprofile>3.2</version.microprofile>
<version.derby>10.14.2.0</version.derby>
<version.liberty-maven-plugin>3.3-M3</version.liberty-maven-plugin>
<version.maven-war-plugin>3.2.3</version.maven-war-plugin>
<version.yasson>1.0.5</version.yasson>
<version.cxf-rt-rs-client>3.2.6</version.cxf-rt-rs-client>
<version.javax.json>1.0.4</version.javax.json>
<version.cxf-rt-rs-mp-client>3.3.1</version.cxf-rt-rs-mp-client>
<!-- Liberty configuration -->
<liberty.var.app.context.root>openliberty</liberty.var.app.context.root>
<liberty.var.default.http.port>9080</liberty.var.default.http.port>
<liberty.var.default.https.port>9443</liberty.var.default.https.port>
<testServerHttpPort>7070</testServerHttpPort>
<junit-jupiter.version>5.8.1</junit-jupiter.version>
</properties>
</project>

12
pom.xml
View File

@ -404,7 +404,6 @@
<module>guice</module> <module>guice</module>
<module>hazelcast</module> <module>hazelcast</module>
<module>helidon</module>
<module>apache-httpclient</module> <module>apache-httpclient</module>
<module>httpclient-simple</module> <module>httpclient-simple</module>
<module>hystrix</module> <module>hystrix</module>
@ -471,9 +470,7 @@
<module>mesos-marathon</module> <module>mesos-marathon</module>
<module>metrics</module> <module>metrics</module>
<module>micronaut</module> <module>microservices-modules</module>
<module>microprofile</module>
<module>msf4j</module>
<module>muleesb</module> <module>muleesb</module>
<module>mustache</module> <module>mustache</module>
<module>mybatis</module> <module>mybatis</module>
@ -481,7 +478,6 @@
<module>netflix-modules</module> <module>netflix-modules</module>
<module>netty</module> <module>netty</module>
<module>ninja</module> <module>ninja</module>
<module>open-liberty</module>
<module>orika</module> <module>orika</module>
<module>osgi</module> <module>osgi</module>
@ -826,7 +822,6 @@
<module>guice</module> <module>guice</module>
<module>hazelcast</module> <module>hazelcast</module>
<module>helidon</module>
<module>apache-httpclient</module> <module>apache-httpclient</module>
<module>httpclient-simple</module> <module>httpclient-simple</module>
<module>hystrix</module> <module>hystrix</module>
@ -895,9 +890,7 @@
<module>mesos-marathon</module> <module>mesos-marathon</module>
<module>metrics</module> <module>metrics</module>
<module>micronaut</module> <module>microservices-modules</module>
<module>microprofile</module>
<module>msf4j</module>
<module>muleesb</module> <module>muleesb</module>
<module>mustache</module> <module>mustache</module>
<module>mybatis</module> <module>mybatis</module>
@ -905,7 +898,6 @@
<module>netflix-modules</module> <module>netflix-modules</module>
<module>netty</module> <module>netty</module>
<module>ninja</module> <module>ninja</module>
<module>open-liberty</module>
<module>orika</module> <module>orika</module>
<module>osgi</module> <module>osgi</module>