In the previous post, i started explaining Auto-Configuration in Spring Boot. Her the second part.

Other Auto‑Configured Aspects in Spring Boot

Spring Boot also auto-configures many other modules. Same idea:

 add dependency → Spring Boot configures it.


1. Spring Security 

Add:

spring-boot-starter-security

Spring Boot will:

  • Enable basic authentication
  • Protect all endpoints
  • Create default user

Default behavior:

  • Username: user
  • Password: shown in console

Minimal example:

@RestController

public class Hello {

    @GetMapping(„/hello“)

    public String hello() {

        return „secured“;

    }

}

Now /hello is protected automatically.


2. Spring Batch 

Add:

spring-boot-starter-batch

Spring Boot will:

  • Configure job repository
  • Setup transaction management
  • Initialize batch tables (optional)

Example job:

@Bean

public Job job(JobBuilderFactory jobBuilderFactory) {

    return jobBuilderFactory.get(„demoJob“).start(step()).build();

}

You only define steps, Boot handles infrastructure.


3. Spring AOP (Aspect-Oriented Programming)

Add:

spring-boot-starter-aop

Spring Boot will:

  • Enable proxy-based AOP
  • Configure aspect processing

Example:

@Aspect

@Component

public class LogAspect {

    @Before(„execution(* com.example..(..))“)

    public void log() {

        System.out.println(„Method called“);

    }

}

No manual AOP setup needed.


4. Caching

Add:

spring-boot-starter-cache

Spring Boot will:

  • Enable caching support
  • Auto-configure cache manager (simple or provider if present)

Example:

@Cacheable(„users“)

public User getUser(Long id) {

    return loadFromDB(id);

}

Results cached automatically.


5. Scheduling

No dependency needed (included in core).

Enable:

@EnableScheduling

Example:

@Scheduled(fixedRate = 5000)

public void run() {

    System.out.println(„Runs every 5 seconds“);

}

Scheduler works immediately.


6. Actuator (Monitoring)

Add:

spring-boot-starter-actuator

Spring Boot will expose endpoints:

  • /actuator/health
  • /actuator/info
  • /actuator/metrics

Useful for monitoring your app.


7. Validation

Add:

spring-boot-starter-validation

Spring Boot auto-configures:

  • Hibernate Validator

Example:

public class User {

    @NotNull

    private String name;

}

Hinterlasse einen Kommentar

I’m Iman

Mein Name ist Iman Dabbaghi. Ich arbeite als Senior Software Engineer in der Schweiz. Außerdem interessiere ich mich sehr für gewaltfreie Kommunikation, Bachata-Tanz und Musik sowie fürs die Persönlichkeitsentwicklung.

Ich habe einen Masterabschluss in Informatik von der Universität Freiburg in Deutschland, bin Spring/Java Certified Professional (OCP), Certified Professional for Software Architecture (CPSA-F) und ein lebenslanger Lernender 🎓.

EN:

My name is Iman Dabbaghi. I work as a Senior Software Engineer in Switzerland. I am also very interessted in nonviolent communication, Bachata dance and music and also for personal development.

I hold a masters degree in computer science from the university of Freiburg in Germany, am a Spring / Java Certified Professional (OCP), Certified Software Architecture (CPSA-F) and Life Long Learner🎓

Let’s connect