Skip to content

Commit e9409e8

Browse files
authored
Merge pull request eugenp#12066 from priya-soni/master
BAEL-5329 - Updated code module
2 parents cd9853a + b18c2e5 commit e9409e8

7 files changed

Lines changed: 44 additions & 7 deletions

File tree

spring-boot-modules/spring-boot-mvc-4/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ This module contains articles about Spring Web MVC in Spring Boot projects.
88
- [Guide to Spring WebUtils and ServletRequestUtils](https://www.baeldung.com/spring-webutils-servletrequestutils)
99
- [Configure a Spring Boot Web Application](https://www.baeldung.com/spring-boot-application-configuration)
1010
- [A Guide to Spring in Eclipse STS](https://www.baeldung.com/eclipse-sts-spring)
11-
- More articles: [[<-- Prev]](/spring-boot-modules/spring-boot-mvc-3)

spring-boot-modules/spring-boot-mvc-4/pom.xml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
56
<modelVersion>4.0.0</modelVersion>
67
<artifactId>spring-boot-mvc-4</artifactId>
78
<name>spring-boot-mvc-4</name>
89
<packaging>jar</packaging>
910
<description>Module For Spring Boot MVC Web</description>
10-
11+
1112
<parent>
1213
<groupId>com.baeldung.spring-boot-modules</groupId>
1314
<artifactId>spring-boot-modules</artifactId>
@@ -19,13 +20,27 @@
1920
<groupId>org.springframework.boot</groupId>
2021
<artifactId>spring-boot-starter-web</artifactId>
2122
</dependency>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
26+
</dependency>
2227
<dependency>
2328
<groupId>org.springframework.boot</groupId>
2429
<artifactId>spring-boot-starter-validation</artifactId>
2530
</dependency>
2631
<dependency>
2732
<groupId>org.springframework.boot</groupId>
28-
<artifactId>spring-boot-starter-thymeleaf</artifactId>
33+
<artifactId>spring-boot-devtools</artifactId>
34+
<optional>true</optional>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.springfox</groupId>
38+
<artifactId>springfox-boot-starter</artifactId>
39+
<version>${spring.fox.version}</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.fasterxml.jackson.core</groupId>
43+
<artifactId>jackson-databind</artifactId>
2944
</dependency>
3045
<dependency>
3146
<groupId>org.springframework.boot</groupId>
@@ -42,4 +57,23 @@
4257
</dependency>
4358
</dependencies>
4459

60+
<build>
61+
<plugins>
62+
<plugin>
63+
<groupId>org.springframework.boot</groupId>
64+
<artifactId>spring-boot-maven-plugin</artifactId>
65+
<configuration>
66+
<mainClass>${start-class}</mainClass>
67+
<layout>JAR</layout>
68+
</configuration>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
73+
74+
<properties>
75+
<spring.fox.version>3.0.0</spring.fox.version>
76+
<start-class>com.baeldung.springboot.swagger.ArticleApplication</start-class>
77+
</properties>
78+
4579
</project>

spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java renamed to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.context.annotation.Bean;
66

7+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
78
import springfox.documentation.builders.PathSelectors;
89
import springfox.documentation.builders.RequestHandlerSelectors;
910
import springfox.documentation.spi.DocumentationType;
@@ -12,6 +13,7 @@
1213

1314
@SpringBootApplication
1415
@EnableSwagger2
16+
@EnableWebMvc
1517
public class ArticleApplication {
1618

1719
public static void main(String[] args) {

spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java renamed to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public List<Article> getAllArticles() {
2121
}
2222

2323
@PostMapping("")
24-
public void addArticle(@RequestBody Article article) {
24+
public void addArticle(@ModelAttribute Article article) {
2525
articleService.addArticle(article);
2626
}
2727

spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java renamed to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class Article {
1515
//@ApiModelProperty(hidden = true)
1616
//@ApiParam(hidden = true)
1717
//@ApiModelProperty(readOnly = true)
18+
@ApiParam(hidden = true)
1819
private int id;
1920
private String title;
2021
private int numOfWords;

spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java renamed to spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public void addArticle(Article article) {
2020
article.setId(articles.size() + 1);
2121
articles.add(article);
2222
}
23-
23+
2424

2525
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Welcome to Baeldung

0 commit comments

Comments
 (0)