Main Spring Boot application class Automatically Component scans sub-package
includes "controller" sub package
Any other sub-package you create can give them any name
- Default scanning is fine if everything is under
- com.app.sprinboot.controller
-
But what about my other package?
- com.jbb
- javablackbook.com
- code.com4.devops
package com.code4devops.springbootjar;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages={"com.jbb",
"javablackbook.com",
"code.com4.devops"})
public class SpringBootJarApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootJarApplication.class, args);
}
}
Application Properties
- By default, Spring Boot Will load properties from:application.properties
- Create By Spring Initializr,Empty at the Beginning
Example : Save As
application.properties
#can add spring boot properties
server.port=8585
#Also Add you own custom properties
code4devops.com=Ashutosh
code4devops.com=Shiva
static Content
- by default ,Spring Boot will load static resource from "/static" directory
- Examples: of static resource HTML files,CSS,Javascript,image
WARNING:
- Do Not use the src/main/webapp directory if our application is packaged as a JAR
- Although this is a standard Maven Directory,it works only with WAR packaing
- It is silently ignored by most build tools if you generate a JAR
Templates
-
Spring Boot includes auto-configuration for following template engines
- FreeMarker
- Thymeleaf(is popular template engine)
- Mustache
- by default ,Spring Boot will load templates from "/templates" directory