Skip to content

Commit cc1fa5b

Browse files
committed
build: Added spring-petclinic sample
1 parent 7cd170c commit cc1fa5b

File tree

74 files changed

+20126
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+20126
-93
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ EXPOSE 8080
1010

1111
RUN mkdir /app
1212

13-
COPY --from=build /app/demo/redis-smart-cache-demo/build/libs/redis-smart-cache-demo-*.jar /app/redis-smart-cache-demo.jar
13+
COPY --from=build /app/samples/redis-smart-cache-demo/build/libs/redis-smart-cache-demo-*.jar /app/redis-smart-cache-demo.jar
1414

1515
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/redis-smart-cache-demo.jar"]

README.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:product-name: Redis Smart Cache
88
:artifact-id: redis-smart-cache-jdbc
99
:property-prefix: smartcache
10-
:grafana-dir: demo/redis-smart-cache-demo/grafana
10+
:grafana-dir: samples/redis-smart-cache-demo/grafana
1111
:imagesdir: src/media
1212
:toc:
1313
:toc-title:

build.gradle

+9-10
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,7 @@ config {
3535

3636
docs {
3737
javadoc {
38-
options {
39-
autoLinks {
40-
enabled = false
41-
}
42-
}
43-
aggregate {
44-
enabled = false
45-
}
38+
enabled = false
4639
}
4740
}
4841

@@ -95,12 +88,18 @@ subprojects {
9588
}
9689

9790
dependencies {
98-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
91+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api'
92+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params'
93+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine'
94+
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher'
95+
testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: testcontainersVersion
96+
testImplementation(group: 'com.redis', name: 'testcontainers-redis', version: testcontainersRedisVersion) {
97+
exclude group: 'com.redis', module: 'lettucemod'
98+
}
9999
}
100100

101101
test {
102102
useJUnitPlatform()
103-
maxHeapSize = "1g" // maximum heap size
104103
}
105104

106105
configurations.all {

core/redis-smart-cache-core/redis-smart-cache-core.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
dependencies {
22
implementation group: 'com.redis', name: 'lettucemod', version: lettucemodVersion
3-
implementation 'org.springframework:spring-beans'
43
implementation 'com.fasterxml.jackson.core:jackson-databind'
54
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-properties'
65
implementation group: 'io.airlift', name: 'units', version: airliftVersion
76
implementation 'io.micrometer:micrometer-registry-jmx'
87
implementation group: 'com.redis', name: 'micrometer-registry-redis', version: micrometerRedisVersion
98
testImplementation group: 'org.awaitility', name: 'awaitility', version: awaitilityVersion
10-
testImplementation group: 'com.redis.testcontainers', name: 'testcontainers-redis-junit', version: testcontainersRedisVersion
119
}
1210

1311
bootJar {

core/redis-smart-cache-core/src/main/java/com/redis/smartcache/core/ClientManager.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import java.util.logging.Level;
66
import java.util.logging.Logger;
77

8-
import org.springframework.util.ObjectUtils;
9-
import org.springframework.util.StringUtils;
10-
118
import com.redis.lettucemod.RedisModulesClient;
129
import com.redis.lettucemod.cluster.RedisModulesClusterClient;
1310
import com.redis.smartcache.core.config.RedisConfig;
@@ -37,8 +34,8 @@ private AbstractRedisClient createClient(RedisConfig config) {
3734

3835
private RedisURI redisURI(RedisConfig config) {
3936
RedisURI.Builder builder = RedisURI.builder(RedisURI.create(config.getUri()));
40-
if (!ObjectUtils.isEmpty(config.getPassword())) {
41-
if (StringUtils.hasLength(config.getUsername())) {
37+
if (config.getPassword() != null && config.getPassword().length > 0) {
38+
if (config.getUsername() != null && config.getUsername().length() > 0) {
4239
builder.withAuthentication(config.getUsername(), config.getPassword());
4340
} else {
4441
builder.withPassword(config.getPassword());

core/redis-smart-cache-jdbc/redis-smart-cache-jdbc.gradle

+2-10
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ dependencies {
1212
testImplementation 'com.mysql:mysql-connector-j'
1313
testImplementation group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: mssqlVersion
1414
testImplementation group: 'com.ibm.db2', name: 'jcc', version: db2Version
15-
testImplementation group: 'com.redis.testcontainers', name: 'testcontainers-redis-junit', version: testcontainersRedisVersion
1615
testImplementation group: 'org.testcontainers', name: 'postgresql', version: testcontainersVersion
1716
testImplementation group: 'org.testcontainers', name: 'oracle-xe', version: testcontainersVersion
1817
testImplementation group: 'org.testcontainers', name: 'mssqlserver', version: testcontainersVersion
@@ -32,17 +31,10 @@ jar.finalizedBy shadowJar
3231

3332
shadowJar {
3433
archiveClassifier = ''
34+
enableRelocation = true
35+
relocationPrefix = "com.redis.smartcache.shaded"
3536
}
3637

37-
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
38-
39-
task relocateShadowJar(type: ConfigureShadowRelocation) {
40-
target = tasks.shadowJar
41-
prefix = "com.redis.smartcache.shaded"
42-
}
43-
44-
tasks.shadowJar.dependsOn tasks.relocateShadowJar
45-
4638
jmh {
4739
fork = 1
4840
iterations = 1

core/redis-smart-cache-jdbc/src/jmh/java/com/redis/smartcache/SqlHashingBenchmark.java

-28
This file was deleted.

docker-compose-test.yml

+7
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ services:
3333
container_name: redis-server-with-cache-cli
3434
ports:
3535
- 6379:6379
36+
37+
redis-cache:
38+
image: redis:7.0.12
39+
hostname: redis-cache
40+
container_name: redis-cache
41+
ports:
42+
- 6380:6379

gradle.properties

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
group = com.redis
2-
sourceCompatibility = 1.8
3-
targetCompatibility = 1.8
42
reproducibleBuild = true
53

6-
bootPluginVersion = 2.7.14
7-
kordampBuildVersion = 3.1.0
8-
kordampPluginVersion = 0.51.0
9-
shadowPluginVersion = 7.1.2
4+
bootPluginVersion = 3.2.1
5+
kordampBuildVersion = 3.4.0
6+
kordampPluginVersion = 0.54.0
7+
shadowPluginVersion = 8.1.1
108
jmhPluginVersion = 0.7.0
119
asciidoctorVersion = 3.3.2
1210

1311
airliftVersion = 1.7
1412
awaitilityVersion = 4.2.0
1513
checkerVersion = 3.12.0
1614
db2Version = 11.5.8.0
17-
datafakerVersion = 1.9.0
18-
jacocoVersion = 0.8.10
19-
lettucemodVersion = 3.7.2
20-
lettuceVersion = 6.2.5.RELEASE
15+
datafakerVersion = 2.0.2
16+
errorproneVersion = 2.21.1
17+
jacocoVersion = 0.8.11
18+
lettucemodVersion = 3.7.3
19+
lettuceVersion = 6.2.6.RELEASE
2120
micrometerRedisVersion = 0.5.1
2221
mssqlVersion = 12.2.0.jre8
23-
progressbarVersion = 0.9.5
24-
testcontainersRedisVersion = 1.6.4
25-
testcontainersVersion = 1.18.3
22+
progressbarVersion = 0.10.0
23+
testcontainersRedisVersion = 2.0.1
24+
testcontainersVersion = 1.19.1
2625
trinoVersion = 422
26+
webjarsBootstrapVersion = 5.3.2
27+
webjarsFontawesomeVersion = 4.7.0
2728

2829
org.gradle.daemon = false
2930
org.gradle.caching = false

gradle/wrapper/gradle-wrapper.jar

-17.7 KB
Binary file not shown.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

+17-12
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,26 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

200-
# Collect all arguments for the java command;
201-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202-
# shell script including quotes and variable substitutions, so put them in
203-
# double quotes to make sure that they get re-expanded; and
204-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
205210

206211
set -- \
207212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

jreleaser.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ distributions:
8585
redis-smart-cache-demo:
8686
type: SINGLE_JAR
8787
artifacts:
88-
- path: 'demo/{{distributionName}}/build/libs/{{distributionName}}-{{projectVersion}}.jar'
88+
- path: 'samples/{{distributionName}}/build/libs/{{distributionName}}-{{projectVersion}}.jar'
8989
transform: '{{distributionName}}/{{distributionName}}-{{projectEffectiveVersion}}.jar'
9090
executable:
9191
name: 'redis-smart-cache-demo-launcher'

samples/spring-petclinic/README.adoc

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
= Spring PetClinic Sample Application
2+
3+
== Run Petclinic locally
4+
5+
Spring Petclinic is a https://spring.io/guides/gs/spring-boot[Spring
6+
Boot] application built using https://spring.io/guides/gs/gradle/[Gradle].
7+
You can build a jar file and run it from the command line (it should work just as well with Java 17 or newer):
8+
9+
[source,bash]
10+
----
11+
./gradlew build
12+
java -jar build/libs/*.jar
13+
----
14+
15+
You can then access the Petclinic at http://localhost:8080/.
16+
17+
Or you can run it from Gradle directly using the Spring Boot Gradle
18+
plugin. If you do this, it will pick up changes that you make in the
19+
project immediately (changes to Java source files require a compile as
20+
well - most people use an IDE for this):
21+
22+
[source,bash]
23+
----
24+
./gradlew bootRun
25+
----
26+
27+
== Database configuration
28+
29+
A setup is provided for MySQL.
30+
31+
You can start MySQL locally with whatever installer works for your OS or use docker:
32+
33+
[source,bash]
34+
----
35+
docker run -e MYSQL_USER=petclinic -e MYSQL_PASSWORD=petclinic -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:8.2
36+
----
37+
38+
Further documentation is provided for https://github.com/spring-projects/spring-petclinic/blob/main/src/main/resources/db/mysql/petclinic_db_setup_mysql.txt[MySQL].
39+
40+
== Working with Petclinic in your IDE
41+
42+
=== Prerequisites
43+
44+
The following items should be installed in your system:
45+
46+
* Java 17 or newer (full JDK, not a JRE)
47+
* https://help.github.com/articles/set-up-git[Git command line tool]
48+
* Your preferred IDE
49+
** Eclipse with the m2e plugin. Note: when m2e is available, there is an
50+
m2 icon in `Help -> About` dialog. If m2e is not there, follow the
51+
install process https://www.eclipse.org/m2e/[here]
52+
** https://spring.io/tools[Spring Tools Suite] (STS)
53+
** https://www.jetbrains.com/idea/[IntelliJ IDEA]
54+
** https://code.visualstudio.com[VS Code]
55+
56+
=== Steps
57+
58+
[arabic]
59+
. On the command line run:
60+
+
61+
[source,bash]
62+
----
63+
git clone https://github.com/spring-projects/spring-petclinic.git
64+
----
65+
. Inside Eclipse or STS:
66+
+
67+
Open the project via
68+
`File -> Import -> Maven -> Existing Maven project`, then select the
69+
root directory of the cloned repo.
70+
+
71+
Then either build on the command line `./mvnw generate-resources` or use
72+
the Eclipse launcher (right-click on project and
73+
`Run As -> Maven install`) to generate the CSS. Run the application’s
74+
main method by right-clicking on it and choosing
75+
`Run As -> Java Application`.
76+
. Inside IntelliJ IDEA:
77+
+
78+
In the main menu, choose `File -> Open` and select the Petclinic
79+
pom.xml. Click on the `Open` button.
80+
* CSS files are generated from the Maven build. You can build them on
81+
the command line `./mvnw generate-resources` or right-click on the
82+
`spring-petclinic` project then
83+
`Maven -> Generates sources and Update Folders`.
84+
* A run configuration named `PetClinicApplication` should have been
85+
created for you if you’re using a recent Ultimate version. Otherwise,
86+
run the application by right-clicking on the `PetClinicApplication` main
87+
class and choosing `Run 'PetClinicApplication'`.
88+
. Navigate to the Petclinic
89+
+
90+
Visit http://localhost:8080 in your browser.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "2.2"
2+
3+
services:
4+
mysql:
5+
image: mysql:8.2
6+
ports:
7+
- "3306:3306"
8+
environment:
9+
- MYSQL_ROOT_PASSWORD=
10+
- MYSQL_ALLOW_EMPTY_PASSWORD=true
11+
- MYSQL_USER=petclinic
12+
- MYSQL_PASSWORD=petclinic
13+
- MYSQL_DATABASE=petclinic
14+
volumes:
15+
- "./conf.d:/etc/mysql/conf.d:ro"
16+
17+
redis:
18+
image: redis/redis-stack-server
19+
hostname: redis
20+
ports:
21+
- 6379:6379

0 commit comments

Comments
 (0)