Skip to content

Commit 551de3b

Browse files
committed
修正配置及初始化脚本
1 parent 5488494 commit 551de3b

12 files changed

+89
-44
lines changed

examples/boot-api/pom.xml

+24
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,28 @@
121121
</plugin>
122122
</plugins>
123123
</build>
124+
<profiles>
125+
<profile>
126+
<id>refresh-db</id>
127+
<build>
128+
<plugins>
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-antrun-plugin</artifactId>
132+
<configuration>
133+
<target>
134+
<property file="src/main/resources/application-prod.properties" />
135+
<sql driver="${spring.datasource.driverClassName}" url="${spring.datasource.url}" userid="${spring.datasource.username}"
136+
password="${spring.datasource.password}" onerror="continue" encoding="${project.build.sourceEncoding}">
137+
<classpath refid="maven.test.classpath" />
138+
<transaction src="src/main/resources/schema-h2.sql" />
139+
<transaction src="src/main/resources/data-h2.sql" />
140+
</sql>
141+
</target>
142+
</configuration>
143+
</plugin>
144+
</plugins>
145+
</build>
146+
</profile>
147+
</profiles>
124148
</project>

examples/boot-api/refresh-db.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
mvn antrun:run -Prefresh-db
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
#set H2 in file mode as the production DB
22
spring.jpa.database=H2
3-
43
spring.datasource.driverClassName=org.h2.Driver
5-
spring.datasource.url=jdbc:h2:file:~/.h2/bootservice;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1;
4+
spring.datasource.url=jdbc:h2:file:~/.h2/bootapi;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1;
65
spring.datasource.username=sa
76
spring.datasource.password=
87

98
#disable automatic initialize for embedded H2
9+
spring.jpa.hibernate.ddl-auto=none
1010
spring.datasource.initialize=false
1111

12-
#connection pool
13-
spring.datasource.max-idle=10
12+
#connection pool settings
13+
spring.datasource.initial-size=10
1414
spring.datasource.max-active=100
15+
spring.datasource.min-idle=8
16+
spring.datasource.max-idle=8
17+
#spring.datasource.time-between-eviction-runs-millis=
18+
#spring.datasource.min-evictable-idle-time-millis=
19+
#spring.datasource.max-wait=
1520

16-
# logging
17-
logging.file=/var/log/boot-api.log
18-
logging.level.org.hibernate=WARN
21+
# logging settings
22+
logging.file=/var/log/springside/boot-api.log
23+
#logging.level.org.hibernate=WARN
1924

20-
# tomcat settings
21-
#server.contextPath=/
22-
#server.tomcat.maxThreads=200
25+
# optional tomcat settings
26+
#server.contextPath=/ by default
27+
#server.tomcat.maxThreads=200 by default
28+
#server.tomcat.compression=on(off by default)
29+
#server.tomcat.compressableMimeTypes=application/json,application/xml (text/html, text/xml, and text/plain by default)

examples/boot-api/src/main/resources/application.properties

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
server.port=8080
33
management.port=7002
44

5-
#application
5+
# application settings
66
app.loginTimeoutSecs=600
77

8-
# other
9-
spring.jackson.serialization.INDENT_OUTPUT=true
8+
# db init settings
9+
spring.datasource.platform=h2
1010
spring.datasource.sqlScriptEncoding=UTF-8
11+
spring.jpa.hibernate.ddl-auto=validate
12+
spring.jpa.showsql=false
1113

12-
# disable spring boot strange behavior
14+
# other settings
1315
spring.main.show-banner=false
14-
spring.jpa.hibernate.ddl-auto=none
15-
spring.jpa.showsql=false
16+
spring.jackson.serialization.INDENT_OUTPUT=true
1617

1718
# /info endpoint
1819
info.app.name=Spring Boot WebService Example

examples/boot-api/src/main/resources/schema.sql examples/boot-api/src/main/resources/schema-h2.sql

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ drop table if exists book;
22
drop table if exists account;
33
drop table if exists message;
44

5-
65
create table book (
76
id bigint generated by default as identity,
87
douban_id varchar(64) not null,
98
title varchar(128) not null,
109
url varchar(255),
1110
description varchar(255),
1211
owner_id bigint not null,
13-
onboard_date date,
12+
onboard_date timestamp,
1413
status varchar(32) not null,
1514
borrower_id bigint null,
16-
borrow_date date,
15+
borrow_date timestamp,
1716
primary key (id)
1817
);
1918

@@ -29,6 +28,6 @@ create table message (
2928
id bigint generated by default as identity,
3029
receiver_id bigint null,
3130
message varchar(256),
32-
receive_date date,
31+
receive_date timestamp,
3332
primary key (id)
3433
);

examples/boot-showcase/src/main/resources/application-prod.properties

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,25 @@ spring.datasource.username=sa
66
spring.datasource.password=
77

88
spring.datasource.initialize=false
9+
spring.jpa.hibernate.ddl-auto=none
910

10-
spring.datasource.max-idle=10
11+
spring.datasource.initial-size=10
1112
spring.datasource.max-active=100
13+
spring.datasource.min-idle=8
14+
spring.datasource.max-idle=8
15+
#spring.datasource.time-between-eviction-runs-millis=
16+
#spring.datasource.min-evictable-idle-time-millis=
17+
#spring.datasource.max-wait=
1218

1319
# logging
14-
logging.file=/var/log/boot-showcase.log
15-
logging.level.org.hibernate=WARN
20+
logging.file=/var/log/springside/boot-showcase.log
21+
#logging.level.org.hibernate=WARN
1622

1723
# tomcat settings
18-
#server.contextPath
19-
#server.tomcat.maxThreads
24+
#server.contextPath=/ by default
25+
#server.tomcat.maxThreads=200 by default
26+
#server.tomcat.compression=on(off by default)
27+
#server.tomcat.compressableMimeTypes=application/json,application/xml (text/html, text/xml, and text/plain by default)
2028
#server.address
2129
#server.sessiontimeout
2230

examples/boot-showcase/src/main/resources/application.properties

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
server.port=8080
33
management.port=7002
44

5-
# other
5+
#db init setting
66
spring.datasource.sqlScriptEncoding=UTF-8
7-
http.mappers.json-pretty-print=true
8-
http.mappers.json-sort-keys=true
7+
spring.jpa.hibernate.ddl-auto=validate
8+
spring.jpa.showsql=false
99

10-
# disable spring boot strange behavior
10+
# other
1111
spring.main.show-banner=false
12-
spring.jpa.hibernate.ddl-auto=none
13-
spring.jpa.showsql=false
12+
http.mappers.json-pretty-print=true
13+
http.mappers.json-sort-keys=true
1414

1515
# disable useless endpoints
1616
endpoints.autoconfig.enabled=false
@@ -20,7 +20,7 @@ endpoints.mappings.enabled=false
2020
endpoints.trace.enabled=false
2121
#endpoints.shutdown.enabled=true
2222

23-
# mail
23+
# mail setting
2424
spring.mail.host=smtp.163.com
2525
spring.mail.username=springside@163.com
2626
spring.mail.password=springside123

quick-start.bat

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ call %MVN% clean install
1111
if errorlevel 1 goto error
1212

1313

14-
echo [Step 2] run boot-api project.
14+
echo [Step 2] init db for production mode..
1515
cd ..\examples\boot-api
16+
call %MVN% antrun:run -Prefresh-db
17+
if errorlevel 1 goto error
18+
19+
echo [Step 3] run boot-api project in dev mode.
1620
call %MVN% spring-boot:run
1721
if errorlevel 1 goto error
1822

quick-start.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ if [ $? -ne 0 ];then
1313
exit -1
1414
fi
1515

16-
echo "[Step 2] run boot-api project."
16+
echo "[Step 2] init db for production mode."
1717
cd ../examples/boot-api
18+
mvn antrun:run -Prefresh-db
19+
20+
echo "[Step 3] run boot-api project in dev mode."
1821
mvn spring-boot:run
1922

2023

support/h2/README.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Command to open a H2 web console.
22

33
If the maven script doesn't work, get the h2 jar file and type below command:
44

5-
java -jar h2-1.3.xxx.jar -web -webPort 8090 -browser
5+
java -jar h2-1.4.xxx.jar -web -webPort 8090 -browser
66

77
See the wiki for details:
88

9-
https://github.com/springside/springside4/wiki/H2database
9+
https://github.com/springside/springside4/wiki/H2database

support/h2/pom.xml

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5-
<parent>
6-
<groupId>io.springside</groupId>
7-
<artifactId>springside-parent</artifactId>
8-
<version>4.3.0-SNAPSHOT</version>
9-
<relativePath>../../modules/parent/</relativePath>
10-
</parent>
5+
<groupId>io.springside</groupId>
116
<artifactId>h2-console</artifactId>
7+
<version>5.0.0-SNAPSHOT</version>
128
<name>H2 Console</name>
139
<packaging>pom</packaging>
1410

1511
<dependencies>
1612
<dependency>
1713
<groupId>com.h2database</groupId>
1814
<artifactId>h2</artifactId>
19-
<version>${h2.version}</version>
15+
<version>1.4.190</version>
2016
<scope>runtime</scope>
2117
</dependency>
2218
</dependencies>
@@ -30,7 +26,7 @@
3026
<execution>
3127
<goals>
3228
<goal>java</goal>
33-
</goals>
29+
</goals>
3430
</execution>
3531
</executions>
3632
<configuration>

0 commit comments

Comments
 (0)