Spring / Spring Boot
Enterprise Framework for Web Development with Java.
Getting Started
Create a new Spring Boot Project
Generate a new Spring project with Spring Initializr.
Create a new Spring Boot Project from the CLI
mkdir myapp && cd myapp
# generate new spring project from the command line
curl https://start.spring.io/starter.tgz \
-d artifactId=myapp \
-d name=myapp \
-d 'description=App description' \
-d dependencies=devtools,configuration-processor,web |
tar -xzvf -
Application Configuration
Global configuration can be done in application.properties
files or YAML files.
## change application port
server.port=8081
## debug configuration
debug=true
trace=true
# troubleshoot authentication
logging.level.springframework.security=debug
## misc
# enable actuator for all endpoints
management.endpoints.web.exposure.include=*
You can also override configurationo through environment variables.
I.e LOGGING_LEVEL_COM_EXAMPLE_PACKAGE
ConfigurationProperties class
Allows to read in properties under the prefix into a class.
@ConfigurationProperties(prefix="mail")
class MyProperties {
private String hostName;
private int port;
private String from;
}
Security
JWT io Library
- use parseClaimsJwt instead of parse. See source
Further Resources
Databases
MongoDB
Spring Data MongoDB Docs: https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongodb-template-query.criteria