Skip to content

ssserj/spring-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Demo

Basic Spring App

mvn clean package
java -jar target/demo-0.0.1-SNAPSHOT.jar

Expected result:

 :: Spring Boot ::                (v3.5.8)
 
2025-11-22T15:35:34.140+03:00  INFO 41206 --- [demo] [           main] com.example.demo.DemoApplication         : Starting DemoApplication using Java 21.0.9 with PID 41206 (/Users/s.sergeev/Code/demo-spring/target/classes started by s.sergeev in /Users/s.sergeev/Code/demo-spring)
2025-11-22T15:35:34.141+03:00  INFO 41206 --- [demo] [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2025-11-22T15:35:34.272+03:00  INFO 41206 --- [demo] [           main] com.example.demo.DemoApplication         : Started DemoApplication in 0.243 seconds (process running for 0.402)
2025-11-22T15:35:34.274+03:00  INFO 41206 --- [demo] [           main] com.example.demo.service.PrototypeBean   : PrototypeBean is called with name name1
PrototypeBean is called with name name1
PrototypeBean is called by beanFactory at 2025-11-22T15:35:34.274535
PrototypeBean is called by singletonBean at 2025-11-22T15:35:34.274572
2025-11-22T15:35:34.274+03:00  INFO 41206 --- [demo] [           main] com.example.demo.service.PrototypeBean   : PrototypeBean is called with name name2
PrototypeBean is called with name name2
PrototypeBean is called by beanFactory at 2025-11-22T15:35:34.274732
PrototypeBean is called by singletonBean at 2025-11-22T15:35:34.274750
2025-11-22T15:35:34.274+03:00  INFO 41206 --- [demo] [           main] com.example.demo.service.PrototypeBean   : PrototypeBean is called with name name3
PrototypeBean is called with name name3
PrototypeBean is called by beanFactory at 2025-11-22T15:35:34.274879
PrototypeBean is called by singletonBean at 2025-11-22T15:35:34.274891

AOT-processed Spring App

mvn clean package && mvn spring-boot:process-aot
java -Dspring.aot.enabled=true -jar target/demo-0.0.1-SNAPSHOT.jar

Produce error:

 :: Spring Boot ::                (v3.5.8)

2025-11-22T15:36:32.254+03:00  INFO 41605 --- [demo] [           main] com.example.demo.DemoApplication         : Starting AOT-processed DemoApplication using Java 21.0.9 with PID 41605 (/Users/s.sergeev/Code/demo-spring/target/classes started by s.sergeev in /Users/s.sergeev/Code/demo-spring)
2025-11-22T15:36:32.254+03:00  INFO 41605 --- [demo] [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2025-11-22T15:36:32.307+03:00  INFO 41605 --- [demo] [           main] com.example.demo.DemoApplication         : Started DemoApplication in 0.168 seconds (process running for 0.326)
2025-11-22T15:36:32.308+03:00  INFO 41605 --- [demo] [           main] com.example.demo.service.PrototypeBean   : PrototypeBean is called with name name1
PrototypeBean is called with name name1
PrototypeBean is called by beanFactory at 2025-11-22T15:36:32.309653
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "com.example.demo.service.SingletonBean.getTime()" because "this.singletonBean" is null
	at com.example.demo.service.PrototypeBean.process(PrototypeBean.java:58)
	at com.example.demo.service.ProcessorBean.process(ProcessorBean.java:35)
	at com.example.demo.DemoApplication.main(DemoApplication.java:15)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages