Skip to content

Commit 55dde06

Browse files
authored
Handle startup warnings (#435)
* Fix access mesage format * Add a default value for POSTGRES_INSTANCE locally * PostgreSQLDialect does not need to be specified explicitly * Fix access log misconfiguration * Suppress unnecessary warnings
1 parent 26df37b commit 55dde06

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
# custom properties used when "postgres-local" Profile is used
2-
spring.datasource.url=jdbc:postgresql://${POSTGRES_INSTANCE}:5432/klass
2+
spring.datasource.url=jdbc:postgresql://${POSTGRES_INSTANCE:localhost}:5432/klass
33
spring.datasource.username=klass
44
spring.datasource.password=${POSTGRES_PASSWORD}
55
spring.datasource.driverclassName=org.postgresql.Driver
66
spring.jpa.hibernate.ddl-auto=none
77
spring.datasource.hikari.connection-test-query=SELECT 1
88
spring.datasource.hikari.validation-timeout=3000
99
spring.jpa.properties.hibernate.format_sql=true
10-
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
11-
1210
# Flyway
1311
spring.flyway.enabled=true
14-
spring.flyway.url=jdbc:postgresql://${POSTGRES_INSTANCE}:5432/klass
12+
spring.flyway.url=jdbc:postgresql://${POSTGRES_INSTANCE:localhost}:5432/klass
1513
spring.flyway.password=${POSTGRES_PASSWORD}
1614
spring.flyway.user=klass
1715
spring.flyway.locations=classpath:db/migration
1816
# This is for first time running on a database with data, but no flyway schema history table
19-
spring.flyway.baseline-on-migrate=true
17+
spring.flyway.baseline-on-migrate=true

klass-api/src/main/resources/application-postgres.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ spring.datasource.hikari.connection-test-query=SELECT 1
55
spring.datasource.hikari.data-source-properties.tcpKeepAlive=true
66
spring.datasource.hikari.connection-timeout=60000
77
spring.datasource.hikari.maximum-pool-size=25
8-
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
98
# Flyway
109
spring.flyway.enabled=true
1110
spring.flyway.url=${NAIS_DATABASE_KLASS_KLASS_JDBC_URL}

klass-api/src/main/resources/application.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ info.build.version=@project.version@
1111
# Profiles for development
1212
# small-import = imports a small number of classifications from legacy system, useful during development
1313
# mock-mailserver = outgoing emails are only logged
14-
# h2 = use h2 database (stored on your filesystem)
15-
# h2-inmemory = use h2 database but keep everything in memory only.(tests must use h2-inmemory)
1614
# embedded-postgres = use embedded postgresql for testing with postgres engine
1715
# postgres-local = postgresql database (local container)
1816
#----------------------
@@ -54,7 +52,11 @@ spring.main.allow-bean-definition-overriding=true
5452
spring.jackson.time-zone=UTC
5553
# Required when running behind a load balancer or reverse proxy server
5654
server.forward-headers-strategy=NATIVE
55+
# Prevent unnecessary logs
56+
logging.level.org.springdoc.core.events.SpringDocAppInitializer=ERROR
5757
springdoc.api-docs.enabled=true
5858
springdoc.swagger-ui.enabled=true
5959
# Prevent runtime warnings about missing jars
6060
server.tomcat.additional-tld-skip-patterns=*.jar
61+
# Several queries are dependent on this functionality
62+
spring.jpa.open-in-view=true

klass-api/src/main/resources/logback-access.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
<OnMatch>DENY</OnMatch>
1313
</filter>
1414
<encoder class="net.logstash.logback.encoder.LogstashAccessEncoder">
15+
<messagePattern>%requestURL - %statusCode - %i{User-Agent}</messagePattern>
1516
<fieldNames>
16-
<messagePattern>%requestURL - %statusCode - %i{User-Agent}</messagePattern>
1717
<requestHeaders>request_headers</requestHeaders>
1818
<responseHeaders>response_headers</responseHeaders>
1919
</fieldNames>
20-
<pattern>
20+
<provider class="net.logstash.logback.composite.loggingevent.LoggingEventPatternJsonProvider">
2121
<pattern>
2222
{
2323
"context": "klass-api",
2424
"logger_name": "tomcat.access",
2525
"level": "INFO"
2626
}
2727
</pattern>
28-
</pattern>
28+
</provider>
2929
</encoder>
3030
</appender>
3131
<appender-ref ref="accessJsonConsoleAppender"/>

0 commit comments

Comments
 (0)