BAEL-5329 : Updated code module
This commit is contained in:
parent
ce9fa68436
commit
d8b5ab0111
4
spring-boot-modules/spring-boot-mvc-4/README.md
Normal file
4
spring-boot-modules/spring-boot-mvc-4/README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
## Spring Boot MVC
|
||||||
|
|
||||||
|
This module contains articles about Spring Web MVC in Spring Boot projects.
|
||||||
|
|
62
spring-boot-modules/spring-boot-mvc-4/pom.xml
Normal file
62
spring-boot-modules/spring-boot-mvc-4/pom.xml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>spring-boot-mvc-4</artifactId>
|
||||||
|
<name>spring-boot-mvc-4</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>Module For Spring Boot</description>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung.spring-boot-modules</groupId>
|
||||||
|
<artifactId>spring-boot-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
|
<version>${spring.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>${start-class}</mainClass>
|
||||||
|
<layout>JAR</layout>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<spring.fox.version>3.0.0</spring.fox.version>
|
||||||
|
<start-class>com.baeldung.springboot.swagger.ArticleApplication</start-class>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
@ -12,6 +13,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
|
@EnableWebMvc
|
||||||
public class ArticleApplication {
|
public class ArticleApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
@ -21,7 +21,7 @@ public class ArticlesController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("")
|
@PostMapping("")
|
||||||
public void addArticle(@RequestBody Article article) {
|
public void addArticle(@ModelAttribute Article article) {
|
||||||
articleService.addArticle(article);
|
articleService.addArticle(article);
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,7 @@ public class Article {
|
|||||||
//@ApiModelProperty(hidden = true)
|
//@ApiModelProperty(hidden = true)
|
||||||
//@ApiParam(hidden = true)
|
//@ApiParam(hidden = true)
|
||||||
//@ApiModelProperty(readOnly = true)
|
//@ApiModelProperty(readOnly = true)
|
||||||
|
@ApiParam(hidden = true)
|
||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
private int numOfWords;
|
private int numOfWords;
|
@ -20,6 +20,6 @@ public class ArticleService {
|
|||||||
article.setId(articles.size() + 1);
|
article.setId(articles.size() + 1);
|
||||||
articles.add(article);
|
articles.add(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1 @@
|
|||||||
|
Welcome to Baeldung
|
Loading…
x
Reference in New Issue
Block a user