Skip to content

palashencode/springboot-ref

Repository files navigation

Project Specific Documentation

This is a reference spring project showing different functionalities. The idea is to use this as a reference for copying out snippets and functionalities.

Imp VM Parameters:

  • -Dfile.encoding=UTF-8 ( to read sql initialization script properly )
  • -Dsecret.api.value=secretValue
  • -Dspring.profiles.active=local ( windows dev )
  • -Dspring.profiles.active=dev ( from unix/deployed instance )

-Xmx512m -Xms512m -Xlog:class+load=info:file=classload.log -Xlog:gc*:file=C:\_TEMP\Logs\GCLogs\gc.log -Xmx512m -Dfile.encoding=UTF-8 -Dsecret.api.value=secretValue -Dspring.profiles.active=local

Local endpoints active are below - all end points are not mapped here. This is to give the user starting point. Please use the swagger for comprehensive list of endpoints.


Logging

The following can be used to set application/package/class level logging

logging.level.root=INFO
logging.level.com.java.springboot.controllers.StatusController=TRACE

Spring Logging Documentation :

Logback

Understanding the current logback config

  • for logback it will create log files in C:\_TEMP\Logs\SpringBootLogs\CustomFileAppender\customLog.log
  • Functionalities ( Console logging, Rolling file logging, Specific java package based logging )
  • Console logging is inherited from <include resource="org/springframework/boot/logging/logback/base.xml" />
  • Additional file logging is done using myRollingFileAppender
  • Specific package based file logging is done with myCustomFileAppender using <logger>
  • LogBook library can be used to log HTTP request/responses
  • Structured logging added with logstash encoder and jsonConsoleAppender appender

Using Log4J

  • add log4j2 dependency and exclude default logging dependency
  • implementation 'org.springframework.boot:spring-boot-starter-log4j2:3.3.4
  • exclude group: "org.springframework.boot", module:"spring-boot-starter-logging"

Using LogBack

  • comment log4j2 dependency and remove spring logging exclude
  • comment implementation 'org.springframework.boot:spring-boot-starter-log4j2:3.3.4
  • commentexclude group: "org.springframework.boot", module:"spring-boot-starter-logging"

Log4j2

References :


Env Controller

View endpoints are as follows

Csv endpoints as follows ( i18n handled by jvm param )

Upload (Multipart) and Download File

swagger screenshot of file upload

Json endpoints as follows :

PDF Controller Using PDF Box : ( i18n achieved with dynamic font loading )

Excel Controller using apache poi :

XML Controller using JAXB :

Xpath Controller :

XSLT Controller :

Protocol Buffer Controller ( save/read from disk ) :

Global Custom Error Handling Page :

Caching and Scheduling, Conditional On Property ( LabelController ) :

TODO

  • @Cacheable
  • @Mockito
  • Java File IO

h2 database configuration

password is 'password'

JVM Params :

  • -Duser.timezone=UTC -Dfile.encoding=utf-8

Intellij Configuration : intellij-config-screen.png


###Features

  • Internationalization added for file encodings
  • save to csv locally & download

###References


Spring Boot Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

Additional Links

These additional references should also help you:

About

simple updated spring boot starter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published