SpringBoot (11) Summing up (I): application.yml file: Configuration for tomcat (parameters, SLL, error), servlets, thymeleaf cache, JPA, messages and our own parameters
1. Tomcat definition in application.yml
The Tomcat definition starts with "server".
1.1 Tomcat: Allowing infinite parameters and special characters in the URL
To allow curly braces "{}"
server.tomcat.relaxed-query-chars: ['{','}']
To allow infinite params
server.tomcat.max-parameter-count: -1
1.2 Tomcat: SSL configuration
To allow SSL
server.ssl.key-store: classpath:keystores/myServerCert.p12
server.ssl.keyStoreType: pkcs12
server.ssl.key-store-password: myPassword
server.ssl.client-auth: need
server.port: 8443
1.3 Tomcat: error stacktrace
To allow showing error stacktrace
Here is the info displayed in the file application.yml referring to Tomcat
#=========================================================
server: #==================================================================================== # 1. For accepting "{ }" in parameters and for accepting a long number of parameters #==================================================================================== #@see https://stackoverflow.com/a/58440058/7704658 #@see https://www.programmersought.com/article/4517808578/ tomcat: relaxed-query-chars: ['{','}'] max-parameter-count: -1 #==================================================================================== # 2. SSL-X05 Authorisation #==================================================================================== #--ssl-x05 autorization @ see https://www.baeldung.com/x-509-authentication-in-spring-security ssl: key-store: classpath:keystores/myServerCert.p12 keyStoreType: pkcs12 key-store-password: myPassword client-auth: need port: 8443 #==================================================================================== # 3. Include stracktrace in the error page #==================================================================================== #--error management #--@see https://www.logicbig.com/tutorials/spring-framework/spring-boot/custom-thymeleaf-error-page.html error: include-stacktrace: always
#=========================================================
2. Servlet multipart files size and Thymeleaf cache
To define multipart file size:
spring.servlet.multipart.max-file-size: 50MB
spring.servlet.multipart.max-request-size: 50MB
Remove cache from Thymeleaf for forcing the refresh of changes
spring.thymeleaf.cache: false
3. JPA definitionTo define multipart file size
For more information see the post about JPA.
#====================================================================
spring: #--JPA datasource: #--Connection Pool hiraki: connectionTimeout: 20000 maximumPoolSize: 5 # PostgreSQL url: jdbc:postgresql://localhost:5432/mywebapp driver-class-name: org.postgresql.Driver username: myUser password: myPassword #--Drop and create jpa: show-sql: true hibernate: ddl-auto: update # ddl-auto: none # generate-ddl: true properties: hibernate: format_sql: true # javax: # persistence: # schema-generation: # scripts: # action: update # create-target: create.sql # create-source: metadata
#====================================================================
4. Messages and i18n files
For instance, the error messages are stored in "src/main/resources/i18n" folder and the files associated with these messages are:
messages_ca_ES.properties, messages_es_ES.properties, messages_es_ES.properties and messages.properties
The same reasoning applies to the error collection of files whose prefix is errors and is stored in the same folder
The part of the application.yml file for this is :
#============================================================
spring: messages: basename: i18n/messages, i18n/errors
#============================================================
5. Other properties for a particular use
For instance, for defining the folder for upload, download, or temporary files these annotations can be made:
#============================================================
folders: upload: /home/ximo/uploads download: /home/ximo/downloads tmp: /home/ximo/tmpkk
#============================================================
Comentarios
Publicar un comentario