Spring¶
All Spring beans are managed - they "live" inside a container, called "application context".
Second, each application has an entry point to that context. Web applications have a Servlet, JSFuses a el-resolver, etc. Also, there is a place where the application context is bootstrapped and all beans - autowired. In web applications this can be a startup listener.
Autowiring happens by placing an instance of one bean into the desired field in an instance of another bean. Both classes should be beans, i.e. they should be defined to live in the application context.
What is "living" in the application context? This means that the context instantiates the objects, not you. I.e. - you never make new UserServiceImpl() - the container finds each injection point and sets an instance there.
Spring and AWS¶
A New Way of Using Email for Support Apps: An AWS Tutorial
Modern Spring Boot 3 Features¶
Spring Boot 3 requires Java 17+ and heavily relies on Jakarta EE 10 instead of Java EE (javax -> jakarta).
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class ModernApplication {
public static void main(String[] args) {
SpringApplication.run(ModernApplication.class, args);
}
}
@RestController
class HelloController {
@GetMapping("/api/hello")
public String hello() {
return "Hello, Spring Boot 3!";
}
}
@Entity
class User {
@Id
private Long id;
private String name;
// Getters and setters
}