Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge staging to prod - added a new section for copyDependencies (#211) #268

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018, 2023 IBM Corporation and others.
// Copyright (c) 2018, 2024 IBM Corporation and others.
// Licensed under Creative Commons Attribution-NoDerivatives
// 4.0 International (CC BY-ND 4.0)
// https://creativecommons.org/licenses/by-nd/4.0/
Expand All @@ -11,7 +11,7 @@
:page-duration: 20 minutes
:page-releasedate: 2018-11-30
:page-description: Learn how to use Java Persistence API (JPA) to access and persist data to a database for your microservices.
:page-tags: ['Jakarta EE']
:page-tags: ['jakarta-ee']
:page-related-guides: ['cdi-intro']
:page-permalink: /guides/{projectid}
:page-guide-category: none
Expand Down Expand Up @@ -299,21 +299,59 @@ EventResource.java
include::finish/backendServices/src/main/java/io/openliberty/guides/event/resources/EventResource.java[]
----

// =================================================================================================
// Configuring the Derby driver and the Liberty
// =================================================================================================

== Configuring the Derby driver and the Liberty Maven plugin

To use a Derby database, you need to download its libraries and store them to the Liberty shared resources directory. Configure the Liberty Maven plug-in in the `pom.xml` file of the `backendServices` service.

[role="code_command hotspot", subs="quotes"]
----
#Replace the `backendServices/pom.xml` configuration file.#
`backendServices/pom.xml`
----

backendServices/pom.xml
[source, xml, linenums, role='code_column']
----
include::finish/backendServices/pom.xml[]
----

server.xml
[source, Xml, linenums, role='code_column']
----
include::finish/backendServices/src/main/liberty/config/server.xml[]
----

This configuration adds three required Derby dependencies to the [hotspot=dependencies file=0]`dependencies` configuration so Maven can download the Derby libraries locally. The [hotspot=copyDependencies file=0]`copyDependencies` configuration instructs the Liberty Maven plug-in to copy the Derby libraries to the Liberty shared resources directory that is specified through the [hotspot=location file=0]`location` configuration, and is referenced in the [hotspot=shared-dir file=1]`derbyJDBCLib` `library` configuration of the `server.xml` file.

In the terminal where you started the `backendServices` microservice, type `r` and press the `enter/return` key to restart the Liberty instance and pick up the Derby libraries.


// =================================================================================================
// Building and running the application
// =================================================================================================

[role=command]
include::{common-includes}/devmode-build.adoc[]
== Running the application

After you see the following message, your Liberty instance is ready in dev mode:

[role="no_copy"]
----
**************************************************************
* Liberty is running in dev mode.
----

// Static guide instruction
ifndef::cloud-hosted[]
When Liberty is running, go to the {eventapp-url} URL to view the Event Manager application.
Go to the {eventapp-url} URL to view the Event Manager application.
endif::[]

// Cloud hosted guide instruction
ifdef::cloud-hosted[]
When Liberty is running, click the following button to view the Event Manager application:
Click the following button to view the Event Manager application:
::startApplication{port="9090" display="external" name="Visit Event Manager application" route="/"}
endif::[]

Expand Down
12 changes: 8 additions & 4 deletions finish/backendServices/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- Liberty configuration -->
<backend.service.http.port>5050</backend.service.http.port>
<backend.service.https.port>5051</backend.service.https.port>
Expand Down Expand Up @@ -60,8 +60,7 @@
<scope>test</scope>
</dependency>
<!-- Derby from https://mvnrepository.com/artifact/org.apache.derby/derby -->
<!-- Use 10.15.2.0 that supports Java 11. -->
<!-- If use 10.16+, need to use Java 17+ -->
<!-- tag::dependencies[] -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
Expand All @@ -80,6 +79,7 @@
<version>10.17.1.0</version>
<scope>provided</scope>
</dependency>
<!-- end::dependencies[] -->
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
Expand All @@ -95,8 +95,11 @@
<artifactId>liberty-maven-plugin</artifactId>
<version>3.10.3</version>
<configuration>
<!-- tag::copyDependencies[] -->
<copyDependencies>
<!-- tag::location[] -->
<location>${project.build.directory}/liberty/wlp/usr/shared/resources</location>
<!-- end::location[] -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
Expand All @@ -110,6 +113,7 @@
<artifactId>derbytools</artifactId>
</dependency>
</copyDependencies>
<!-- end::copyDependencies[] -->
</configuration>
</plugin>
<!-- Plugin to run unit tests -->
Expand Down
2 changes: 2 additions & 0 deletions finish/backendServices/src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
<application location="backendServices.war" type="war" context-root="/"></application>

<!-- Derby Library Configuration -->
<!-- tag::shared-dir[] -->
<library id="derbyJDBCLib">
<fileset dir="${shared.resource.dir}/" includes="derby*.jar" />
</library>
<!-- end::shared-dir[] -->

<!-- Datasource Configuration -->
<!-- tag::data-source[] -->
Expand Down
4 changes: 2 additions & 2 deletions finish/frontendUI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- Liberty configuration -->
<frontend.service.http.port>9090</frontend.service.http.port>
<frontend.service.https.port>9091</frontend.service.https.port>
Expand Down
21 changes: 2 additions & 19 deletions start/backendServices/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- Liberty configuration -->
<backend.service.http.port>5050</backend.service.http.port>
<backend.service.https.port>5051</backend.service.https.port>
Expand Down Expand Up @@ -94,23 +94,6 @@
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.10.3</version>
<configuration>
<copyDependencies>
<location>${project.build.directory}/liberty/wlp/usr/shared/resources</location>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyshared</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
</dependency>
</copyDependencies>
</configuration>
</plugin>
<!-- Plugin to run unit tests -->
<plugin>
Expand Down
4 changes: 2 additions & 2 deletions start/frontendUI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<!-- Liberty configuration -->
<frontend.service.http.port>9090</frontend.service.http.port>
<frontend.service.https.port>9091</frontend.service.https.port>
Expand Down
Loading