Skip to content

Commit 729e25b

Browse files
committed
upgrade Spring Boot version to 4.0.2
fix and configure logback logging fix employee name string concatenation
1 parent f800399 commit 729e25b

3 files changed

Lines changed: 44 additions & 26 deletions

File tree

empire-db-examples/empire-db-example-spring-boot/pom.xml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@
1515
See the License for the specific language governing permissions and
1616
limitations under the License.
1717
-->
18-
<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/maven-v4_0_0.xsd">
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1920
<modelVersion>4.0.0</modelVersion>
20-
21+
2122
<parent>
2223
<artifactId>empire-db-examples</artifactId>
2324
<groupId>org.apache.empire-db</groupId>
2425
<version>3.4.1-SNAPSHOT</version>
2526
</parent>
26-
27+
2728
<name>Apache Empire-db Spring Boot Example</name>
2829
<artifactId>empire-db-example-spring-boot</artifactId>
2930
<packaging>jar</packaging>
3031

3132
<properties>
32-
<spring-boot.version>2.7.17</spring-boot.version>
33+
<spring-boot.version>4.0.2</spring-boot.version>
3334
</properties>
3435

3536
<dependencyManagement>
@@ -49,31 +50,35 @@
4950
<dependency>
5051
<groupId>org.apache.empire-db</groupId>
5152
<artifactId>empire-db</artifactId>
52-
</dependency>
53-
54-
<dependency>
55-
<groupId>org.springframework.boot</groupId>
56-
<artifactId>spring-boot-starter</artifactId>
5753
<exclusions>
58-
<exclusion>
59-
<groupId>ch.qos.logback</groupId>
60-
<artifactId>logback-classic</artifactId>
61-
</exclusion>
54+
<exclusion>
55+
<groupId>log4j</groupId>
56+
<artifactId>log4j</artifactId>
57+
</exclusion>
58+
<exclusion>
59+
<groupId>org.slf4j</groupId>
60+
<artifactId>slf4j-api</artifactId>
61+
</exclusion>
62+
<exclusion>
63+
<groupId>org.slf4j</groupId>
64+
<artifactId>slf4j-reload4j</artifactId>
65+
</exclusion>
6266
</exclusions>
6367
</dependency>
64-
65-
<!-- logging -->
66-
<dependency>
67-
<groupId>org.slf4j</groupId>
68-
<artifactId>slf4j-reload4j</artifactId>
69-
</dependency>
70-
7168
<dependency>
7269
<groupId>org.hsqldb</groupId>
7370
<artifactId>hsqldb</artifactId>
7471
<scope>runtime</scope>
7572
</dependency>
76-
73+
<dependency>
74+
<groupId>org.slf4j</groupId>
75+
<artifactId>slf4j-api</artifactId>
76+
<version>2.0.17</version>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.springframework.boot</groupId>
80+
<artifactId>spring-boot-starter</artifactId>
81+
</dependency>
7782
<dependency>
7883
<groupId>org.springframework.boot</groupId>
7984
<artifactId>spring-boot-starter-jdbc</artifactId>

empire-db-examples/empire-db-example-spring-boot/src/main/java/org/apache/empire/samples/springboot/SampleApp.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,16 @@ private void queryDataList() {
346346
for (DataListEntry dle : list) {
347347
long empId = dle.getRecordId(EMP);
348348
// int depId = dle.getId(DEP);
349-
String empName = StringUtils.concat(", ", dle.getString(EMP.LAST_NAME), dle.getString(EMP.FIRST_NAME));
349+
// Put the comma between last and first name (Last, First)
350+
String empName = StringUtils.concat(dle.getString(EMP.LAST_NAME), ", ", dle.getString(EMP.FIRST_NAME));
350351
String depName = dle.getString(DEP.NAME);
351352
boolean hasPayments = !dle.isNull(Q_EMP_TOTAL.column(EMP_TOTAL));
352353
if (hasPayments) { // report
353354
BigDecimal empTotal = dle.getDecimal(Q_EMP_TOTAL.column(EMP_TOTAL));
354355
BigDecimal pctOfDep = dle.getDecimal(PCT_OF_DEP_COST).setScale(1, RoundingMode.HALF_UP);
355-
LOGGER.info("Eployee[{}]: {}\tDepartment: {}\tPayments: {} ({}% of Department)", empId, empName, depName, empTotal, pctOfDep);
356+
LOGGER.info("Employee[{}]: {}\tDepartment: {}\tPayments: {} ({}% of Department)", empId, empName, depName, empTotal, pctOfDep);
356357
} else {
357-
LOGGER.info("Eployee[{}]: {}\tDepartment: {}\tPayments: [No data avaiable]", empId, empName, depName);
358+
LOGGER.info("Employee[{}]: {}\tDepartment: {}\tPayments: [No data avaiable]", empId, empName, depName);
358359
}
359360
}
360361

@@ -517,10 +518,10 @@ private void queryRecordList() {
517518
for (DBRecordBean record : list) {
518519
Object[] key = record.getKey();
519520
// print info
520-
String empName = StringUtils.concat(", ", record.getString(EMP.LAST_NAME), record.getString(EMP.FIRST_NAME));
521+
String empName = StringUtils.concat(record.getString(EMP.LAST_NAME), ", ", record.getString(EMP.FIRST_NAME));
521522
String phone = record.getString(EMP.PHONE_NUMBER);
522523
BigDecimal salary = record.getDecimal(EMP.SALARY);
523-
LOGGER.info("Eployee[{}]: {}\tPhone: {}\tSalary: {}", StringUtils.toString(key), empName, phone, salary);
524+
LOGGER.info("Employee[{}]: {}\tPhone: {}\tSalary: {}", StringUtils.toString(key), empName, phone, salary);
524525
// modify salary
525526
BigDecimal newSalary = new BigDecimal(2000 + ((Math.random() * 200) - 100.0));
526527
record.set(EMP.SALARY, newSalary);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration debug="true">
3+
<appender name="default" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>[%d{ISO8601} %5p] %40.40c:%4L [%-8t] - %m%n</pattern>
6+
</encoder>
7+
</appender>
8+
9+
<root level="info">
10+
<appender-ref ref="default"/>
11+
</root>
12+
</configuration>

0 commit comments

Comments
 (0)