About Spring Boot Project Structure

  • mvnw allows you to run a Maven project
  • No need to have Maven installed or present on your path
  • If correct version of Maven is NOT found on your computer
  • Automatically downloads correct version and runs Maven
  • Two files are provided
  • mvnw.cmd for MS Windows E:\coder_workstation\spring-boot\spring-boot-jar\spring-boot-jar>mvnw clean compile test
  • mvnw.sh for Linux/Mac ./mvnw clean compile test
  • If you already have Maven installed previously
  • Then you can ignore/delete the mvnw files
  • Just use Maven as you normally would

Maven Standard Directory Structure

Directory Description
src/main/java Java source code
src/main/resource Properties/config files used by your app
src/test/java Unit testing soucre code

mvnw.cmd: first thing mvnw.cmd file for window and mvnw.sh for Linux operating system.both files doing same work depending on the operating system . No need to have Maven installed or present on your path. If the Correct version of Maven is NOT Found on your computer. it Automatically Downloads correct Version and runs Maven if you have correct version install in your computer then delete .mvnw file form spring boot project

pom.xml includes info that you entered at Spring Initializr website

<dependencies>
	<dependency>
	  <groupId>org.springframework.boot</groupId>
	  <artifactId>spring-boot-started-web</artifactId>
	</dependency>
</dependencies>
<dependencies>
	<dependency>
    	<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-started-test</artifactId>
	</dependency>
</dependencies>

About of Spring Boot started dependency

  • A collection of Maven dependencies(Compatible versions)
  • spring-boot-started-web spring-web, spring-webmvc, hibernate-Validator, tomcat, json

Maven POM file

Spring Boot Maven Plugin

<dependencies>
 <dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-maven-plugin</artifactId>
 </dependency>
</dependencies>

About of spring boot maven plugin dependency

  • Use to package executable jar or war archive can also easily run the application
  • $ ./mvnw package
  • $ ./mvnw spring-boot:run

@springBootApplicatin:

(Enables) Auto Configuration, Component scanning ,Additional Configuration

Composed of following annotations

@EnableAutoConfiguration

@ComponentScan

@Configuration

Annotations

@SpringBootApplication is composed of the following annotations:

Annotaion Description
@EnableAutoConfiguration Enables Spring Boot's auto-configuration support
@ComponentScan Enables component scanning of current package Also recursively scans sub-packages
@Configuration Able to register extra beans with @Bean or import other configuration classes

@ComponentScan , @Configuration :Same annotaions that we've used before with traditional Springs Apps

package com.jbb.springboot.MySpringBootApp2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MySpringBootApp2Application {

	public static void main(String[] args) {
		SpringApplication.run(MySpringBootApp2Application.class, args);
	}

}