Skip to content

kpidiba/SPRING-BOOT

Repository files navigation

SPRING-BOOT

Spring boot is   module of spring framework which we speed up the development,It' s provides an easier and faster way to set up, configure and run both simple and web-based applications.

  • Scan the class path and find the dependency it will automatically configure the things.
  • define controller folder in the Main class folder or main package

TABLE OF CONTENT

  1. swagger
  2. deploy
  3. exceptions
  4. hosting
  5. rest-api
  6. thymeleaf
  7. Tricks
  8. MUTLI DATASOURCES CONNECTIONS
  9. PROCEDURE

RESSOURCES

ARCHITECTURE

src
├── main
│   ├── java
│   │   └── com
│   │       └── yourcompany
│   │           └── yourproject
│   │               ├── config         (Application configuration classes)
│   │               ├── controller     (REST API controllers)
│   │               ├── exception      (Custom exception classes)
│   │               ├── model          (Data model classes)
│   │               ├── repository     (Database repositories)
│   │               ├── service        (Business logic services)
│   │               ├── util           (Utility classes)
│   │               ├── Application.java (Main application class)
│   │               └── ...
│   ├── resources
│   │   ├── static       (Static resources like CSS, JS, images)
│   │   ├── templates    (HTML templates, if using server-side rendering)
│   │   ├── application.properties (Application-wide properties)
│   │   ├── application.yml        (YAML configuration, if preferred)
│   │   └── ...
└── test
    ├── java
    │   └── com
    │       └── yourcompany
    │           └── yourproject
    │               ├── controller    (Controller test classes)
    │               ├── service       (Service test classes)
    │               ├── util          (Utility test classes)
    │               ├── ApplicationTests.java (Main test class)
    │               └── ...
    └── resources
        ├── application.properties (Test-specific properties)
        └── ...

Explanation of Key Folders:

  • config: Contains configuration classes, such as beans, security configurations, and other application-wide settings.

  • controller: Houses your REST API controller classes, which handle incoming HTTP requests.

  • exception: Contains custom exception classes, which you can use to handle application-specific errors.

  • model: Stores data model classes, representing your application's entities.(entity,dto)

  • repository: Holds database repository interfaces or classes if you're using a database.

  • service: Houses business logic services that orchestrate interactions between controllers and repositories.

  • util: Contains utility classes that are used across the application.

  • static: This folder holds static resources like CSS, JavaScript, and images, typically used for web applications.

  • templates: If you're using server-side rendering with templating engines like Thymeleaf, this is where your HTML templates would reside.

  • application.properties/application.yml: Configuration files for properties that configure your application. They include database settings, logging levels, etc.

  • test: This folder mirrors the main folder's structure but is dedicated to test classes and resources.

LOGS

logging.file.path=C:/Users/kpidi/logs

APPLICATION PROPERTIES

Application Properties support us to work in different environments. In this chapter, you are going to learn how to configure and specify the properties to a Spring Boot application.

we can keep separate properties file for each profile as shown belowapplication.properties

server.port = 8080
spring.application.name = demoservice
application-dev.properties

server.port = 9090
spring.application.name = demoservice
application-prod.properties

server.port = 4431
spring.application.name = demoservice

application.yml/application.yaml file

The application.properties file is not that readable. So most of the time developers choose application.yml file over application.properties file. YAML is a superset of JSON, and as such is a very convenient format for specifying hierarchical configuration data. YAML is more readable and it is good for the developers to read/write configuration files. For example, let’s pick some of the properties files that we have explained above, and let’s write them in YAML format.

CRUD

JpaRepository extends PagingAndSortingRepository which in turn extends CrudRepository.

Their main functions are:

Because of the inheritance mentioned above, JpaRepository will have all the functions of CrudRepository and PagingAndSortingRepository. So if you don't need the repository to have the functions provided by JpaRepository and PagingAndSortingRepository , use CrudRepository.

Releases

No releases published

Packages

No packages published

Languages