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

  1. Default scanning is fine if everything is under
  2. com.app.sprinboot.controller
  3. But what about my other package?
    1. com.jbb
    2. javablackbook.com
    3. 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

  1. By default, Spring Boot Will load properties from:application.properties
  2. 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

  1. by default ,Spring Boot will load static resource from "/static" directory
  2. 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

  1. Spring Boot includes auto-configuration for following template engines
    1. FreeMarker
    2. Thymeleaf(is popular template engine)
    3. Mustache
  2. by default ,Spring Boot will load templates from "/templates" directory