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"
xmlns="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"
version="2.0"
bean-discovery-mode="annotated">
</beans>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="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"
version="2.0"
bean-discovery-mode="annotated">
</beans>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<artifactId>microservices-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</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 Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@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
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@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_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 e.g. to debug Maven itself, use
@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 ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@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.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
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 location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@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
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
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"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@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.
if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR%
) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR%
)
@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% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@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.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@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
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@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_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 e.g. to debug Maven itself, use
@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 ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@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.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
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 location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@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
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
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"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@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.
if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR%
) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR%
)
@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% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@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.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%

View File

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

View File

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

View File

@ -10,7 +10,7 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<artifactId>microservices-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</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.rest.consumes.RestConsumer;
public class RestClientTest {
public class RestClientLiveTest {
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>hazelcast</module>
<module>helidon</module>
<module>apache-httpclient</module>
<module>httpclient-simple</module>
<module>hystrix</module>
@ -471,9 +470,7 @@
<module>mesos-marathon</module>
<module>metrics</module>
<module>micronaut</module>
<module>microprofile</module>
<module>msf4j</module>
<module>microservices-modules</module>
<module>muleesb</module>
<module>mustache</module>
<module>mybatis</module>
@ -481,7 +478,6 @@
<module>netflix-modules</module>
<module>netty</module>
<module>ninja</module>
<module>open-liberty</module>
<module>orika</module>
<module>osgi</module>
@ -826,7 +822,6 @@
<module>guice</module>
<module>hazelcast</module>
<module>helidon</module>
<module>apache-httpclient</module>
<module>httpclient-simple</module>
<module>hystrix</module>
@ -895,9 +890,7 @@
<module>mesos-marathon</module>
<module>metrics</module>
<module>micronaut</module>
<module>microprofile</module>
<module>msf4j</module>
<module>microservices-modules</module>
<module>muleesb</module>
<module>mustache</module>
<module>mybatis</module>
@ -905,7 +898,6 @@
<module>netflix-modules</module>
<module>netty</module>
<module>ninja</module>
<module>open-liberty</module>
<module>orika</module>
<module>osgi</module>