Skip to content

Commit 0a4efff

Browse files
@EnableAutoConfiguration
1 parent 2b51c67 commit 0a4efff

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE>
2+
<html xmlns="http://www.w3.org/1999/xhtml"
3+
xmlns:th="http://www.thymeleaf.org"
4+
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
5+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
6+
<html>
7+
<body>
8+
<h1>Message has been sent to subscriber.</h1>
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)