1+ package com .javaprogram .auto .configurations ;
2+
3+ import org .slf4j .Logger ;
4+ import org .slf4j .LoggerFactory ;
5+ import org .springframework .beans .factory .annotation .Autowired ;
6+ import org .springframework .boot .SpringApplication ;
7+ import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
8+ import org .springframework .boot .autoconfigure .jms .JmsAutoConfiguration ;
9+ import org .springframework .boot .autoconfigure .security .servlet .SecurityAutoConfiguration ;
10+ import org .springframework .context .annotation .Bean ;
11+ import org .springframework .stereotype .Controller ;
12+ import org .springframework .web .bind .annotation .PostMapping ;
13+
14+ @ EnableAutoConfiguration (exclude = SecurityAutoConfiguration .class , excludeName = "SecurityAutoConfiguration" )
15+ public class AutoConfigureApplication {
16+
17+ @ Bean
18+ public Message getMessage () {
19+ return new Message ();
20+ }
21+
22+ @ Bean
23+ public MessageController getMessageController () {
24+ return new MessageController ();
25+ }
26+
27+ public static void main (String [] args ) {
28+ SpringApplication .run (AutoConfigureApplication .class , args );
29+
30+ }
31+
32+ }
33+
34+ class Message {
35+
36+ public String getMessage () {
37+ return "New message generated" ;
38+ }
39+
40+ }
41+
42+ @ Controller
43+ class MessageController {
44+ Logger logger = LoggerFactory .getLogger (getClass ());
45+
46+ @ Autowired
47+ private Message msg ;
48+
49+ @ PostMapping ("/send" )
50+ public void messageSender () {
51+
52+ String messag = msg .getMessage ();
53+ logger .info ("Message : " + messag );
54+ logger .info ("Message sent...." );
55+
56+ }
57+ }
0 commit comments