环境概述
使用的开发工具:idea 2018 3.4
环境:jdk1.8
数据库:MariaDB (10.2.21)
包管理:Maven 3.5
Web容器:Tomcat 8.0
开发机系统:Window Server 2012
1、新建maven项目
选择 Create from archetype -> 选择如下选项 ,再下一步
填写 GroupId 和 ArtifactId ,再下一步
设置一些基本信息,一般为默认值,再下一步
可以修改项目名称等,一般可以默认,设置完毕选择完成生成项目
Maven手动导入(Import Changes)和自动导入(Enable Auto-Import)选择
2、引用依赖包 pom.xml(注意mysql-connector-java引用Idea默认没有版本号,低版本一定要自己加入)
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.0modelVersion> <groupId>cn.suncsf.test.sfgroupId> <artifactId>mtestartifactId> <version>1.0-SNAPSHOTversion> <name>mtestname> <url>http://www.example.comurl> <properties> <project.build.sourceEncoding>UTF-8project.build.sourceEncoding> <maven.compiler.source>1.8maven.compiler.source> <maven.compiler.target>1.8maven.compiler.target> properties> <parent> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-parentartifactId> <version>2.1.2.RELEASEversion> parent> <dependencies> <dependency> <groupId>junitgroupId> <artifactId>junitartifactId> <version>4.11version> <scope>testscope> dependency> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starterartifactId> dependency> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-webartifactId> dependency> <dependency> <groupId>org.springframework.bootgroupId> <artifactId>spring-boot-starter-thymeleafartifactId> dependency> <dependency> <groupId>org.mybatis.spring.bootgroupId> <artifactId>mybatis-spring-boot-starterartifactId> <version>2.0.0version> dependency> <dependency> <groupId>mysqlgroupId> <artifactId>mysql-connector-javaartifactId> <version>5.1.47version> dependency> <dependency> <groupId>com.alibabagroupId> <artifactId>druidartifactId> <version>1.1.14version> dependency> <dependency> <groupId>io.springfoxgroupId> <artifactId>springfox-swagger2artifactId> <version>2.5.0version> dependency> <dependency> <groupId>io.springfoxgroupId> <artifactId>springfox-swagger-uiartifactId> <version>2.5.0version> dependency> dependencies> <build> <pluginManagement> <plugins> <plugin> <artifactId>maven-clean-pluginartifactId> <version>3.1.0version> plugin> <plugin> <artifactId>maven-resources-pluginartifactId> <version>3.0.2version> plugin> <plugin> <artifactId>maven-compiler-pluginartifactId> <version>3.8.0version> plugin> <plugin> <artifactId>maven-surefire-pluginartifactId> <version>2.22.1version> plugin> <plugin> <artifactId>maven-jar-pluginartifactId> <version>3.0.2version> plugin> <plugin> <artifactId>maven-install-pluginartifactId> <version>2.5.2version> plugin> <plugin> <artifactId>maven-deploy-pluginartifactId> <version>2.8.2version> plugin> <plugin> <artifactId>maven-site-pluginartifactId> <version>3.7.1version> plugin> <plugin> <artifactId>maven-project-info-reports-pluginartifactId> <version>3.0.0version> plugin> plugins> pluginManagement> build> project>
3、添加 resources 资源文件夹
4、新增application.properties文件并如下配置
#设置端口
server.port=8082
#连接驱动
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#数据源名称
spring.datasource.name=mtest
#连接池
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#密码
spring.datasource.password=xxx
#连接地址
spring.datasource.url=jdbc:mysql://localhost:3336/test
#帐号
spring.datasource.username=root
#骆驼峰
mybatis.configuration.map-underscore-to-camel-case=true
#mybatis Mapper文件
mybatis.mapper-locations=classpath:mapping/*.xml
#别名配置
mybatis.type-aliases-package=cn.suncsf.test.sf.mstest.po
5、新建在mysql -> test 数据库中新建t_test数据表
/* Navicat MariaDB Data Transfer Source Server : 本地1 Source Server Version : 100221 Source Host : localhost:3336 Source Database : test Target Server Type : MariaDB Target Server Version : 100221 File Encoding : 65001 Date: 2019-03-25 16:24:08 */ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for t_test -- ---------------------------- DROP TABLE IF EXISTS `t_test`; CREATE TABLE `t_test` ( `t_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, PRIMARY KEY (`t_id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
6、新建T_Test.java PO类、TestDao.java DAO及对应的Mapper文件TestDoMapper.xml
T_Test.java
package cn.suncsf.test.sf.mstest.po; public class T_Test { private int tId; private String name; public int gettId() { return tId; } public void settId(int tId) { this.tId = tId; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
TestDao.java
package cn.suncsf.test.sf.mstest.dao; import cn.suncsf.test.sf.mstest.po.T_Test; import org.springframework.stereotype.Repository; @Repository public interface TestDao { public T_Test findById(Integer tId); }
TestDoMapper.xml
DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
7、新建SwaggerConfig.java配置类
package cn.suncsf.test.sf.mstest.config; import io.swagger.annotations.ApiOperation; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket swaggerSpringMvcPlugin(){ return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .build(); } }
8、添加ApiTestController.java 控制器
package cn.suncsf.test.sf.mstest.controller; import cn.suncsf.test.sf.mstest.dao.TestDao; import cn.suncsf.test.sf.mstest.po.T_Test; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @Api(value = "测试服务") @RestController @RequestMapping(value = "/api/test") public class ApiTestController { @Autowired private TestDao testDao; @ApiOperation(nickname = "获取数据",value = "获取单个数据信息") @RequestMapping(value = "/gettestbyid/{id}") public T_Test getTestById(@PathVariable("id")int id){ return testDao.findById(id); } }
9、配置Spring boot启动类 App.java
package cn.suncsf.test.sf.mstest; import org.mybatis.spring.annotation.MapperScan; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Hello world! * */ @MapperScan(basePackages = {"cn.suncsf.test.sf.mstest.dao"}) @SpringBootApplication(scanBasePackages = {"cn.suncsf.test.sf.mstest"}) public class App { private static final Logger logger = LoggerFactory.getLogger(App.class); public static void main( String[] args ) { logger.info("服务启动"); SpringApplication.run(App.class,args); logger.info("启动结束"); } }
10、启动Spring 项目
"D:\Program Files\Java\jdk1.8.0_171\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\lib\idea_rt.jar=62268:D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\bin" -Dfile.encoding=UTF-8 -classpath "D:\Program Files\Java\jdk1.8.0_171\jre\lib\charsets.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\deploy.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\access-bridge-64.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\cldrdata.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\dnsns.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jaccess.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\jfxrt.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\localedata.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\nashorn.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunec.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunjce_provider.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunmscapi.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\sunpkcs11.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\ext\zipfs.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\javaws.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\jce.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\jfr.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\jfxswt.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\jsse.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\management-agent.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\plugin.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\resources.jar;D:\Program Files\Java\jdk1.8.0_171\jre\lib\rt.jar;F:\project\sjava\mtest\target\classes;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-starter\2.1.2.RELEASE\spring-boot-starter-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot\2.1.2.RELEASE\spring-boot-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\spring-context\5.1.4.RELEASE\spring-context-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-autoconfigure\2.1.2.RELEASE\spring-boot-autoconfigure-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-starter-logging\2.1.2.RELEASE\spring-boot-starter-logging-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;F:\project\mvn\aliyun\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;F:\project\mvn\aliyun\org\apache\logging\log4j\log4j-to-slf4j\2.11.1\log4j-to-slf4j-2.11.1.jar;F:\project\mvn\aliyun\org\apache\logging\log4j\log4j-api\2.11.1\log4j-api-2.11.1.jar;F:\project\mvn\aliyun\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;F:\project\mvn\aliyun\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;F:\project\mvn\aliyun\org\springframework\spring-core\5.1.4.RELEASE\spring-core-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\spring-jcl\5.1.4.RELEASE\spring-jcl-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-starter-web\2.1.2.RELEASE\spring-boot-starter-web-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-starter-json\2.1.2.RELEASE\spring-boot-starter-json-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\com\fasterxml\jackson\core\jackson-databind\2.9.8\jackson-databind-2.9.8.jar;F:\project\mvn\aliyun\com\fasterxml\jackson\core\jackson-core\2.9.8\jackson-core-2.9.8.jar;F:\project\mvn\aliyun\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.8\jackson-datatype-jdk8-2.9.8.jar;F:\project\mvn\aliyun\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.8\jackson-datatype-jsr310-2.9.8.jar;F:\project\mvn\aliyun\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.8\jackson-module-parameter-names-2.9.8.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-starter-tomcat\2.1.2.RELEASE\spring-boot-starter-tomcat-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\org\apache\tomcat\embed\tomcat-embed-core\9.0.14\tomcat-embed-core-9.0.14.jar;F:\project\mvn\aliyun\org\apache\tomcat\embed\tomcat-embed-el\9.0.14\tomcat-embed-el-9.0.14.jar;F:\project\mvn\aliyun\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.14\tomcat-embed-websocket-9.0.14.jar;F:\project\mvn\aliyun\org\hibernate\validator\hibernate-validator\6.0.14.Final\hibernate-validator-6.0.14.Final.jar;F:\project\mvn\aliyun\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;F:\project\mvn\aliyun\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;F:\project\mvn\aliyun\org\springframework\spring-web\5.1.4.RELEASE\spring-web-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\spring-beans\5.1.4.RELEASE\spring-beans-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\spring-webmvc\5.1.4.RELEASE\spring-webmvc-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\spring-aop\5.1.4.RELEASE\spring-aop-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\spring-expression\5.1.4.RELEASE\spring-expression-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-starter-thymeleaf\2.1.2.RELEASE\spring-boot-starter-thymeleaf-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\org\thymeleaf\thymeleaf-spring5\3.0.11.RELEASE\thymeleaf-spring5-3.0.11.RELEASE.jar;F:\project\mvn\aliyun\org\thymeleaf\thymeleaf\3.0.11.RELEASE\thymeleaf-3.0.11.RELEASE.jar;F:\project\mvn\aliyun\org\attoparser\attoparser\2.0.5.RELEASE\attoparser-2.0.5.RELEASE.jar;F:\project\mvn\aliyun\org\unbescape\unbescape\1.1.6.RELEASE\unbescape-1.1.6.RELEASE.jar;F:\project\mvn\aliyun\org\thymeleaf\extras\thymeleaf-extras-java8time\3.0.2.RELEASE\thymeleaf-extras-java8time-3.0.2.RELEASE.jar;F:\project\mvn\aliyun\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.0.0\mybatis-spring-boot-starter-2.0.0.jar;F:\project\mvn\aliyun\org\springframework\boot\spring-boot-starter-jdbc\2.1.2.RELEASE\spring-boot-starter-jdbc-2.1.2.RELEASE.jar;F:\project\mvn\aliyun\com\zaxxer\HikariCP\3.2.0\HikariCP-3.2.0.jar;F:\project\mvn\aliyun\org\springframework\spring-jdbc\5.1.4.RELEASE\spring-jdbc-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\spring-tx\5.1.4.RELEASE\spring-tx-5.1.4.RELEASE.jar;F:\project\mvn\aliyun\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.0.0\mybatis-spring-boot-autoconfigure-2.0.0.jar;F:\project\mvn\aliyun\org\mybatis\mybatis\3.5.0\mybatis-3.5.0.jar;F:\project\mvn\aliyun\org\mybatis\mybatis-spring\2.0.0\mybatis-spring-2.0.0.jar;F:\project\mvn\aliyun\mysql\mysql-connector-java\5.1.47\mysql-connector-java-5.1.47.jar;F:\project\mvn\aliyun\com\alibaba\druid\1.1.14\druid-1.1.14.jar;F:\project\mvn\aliyun\io\springfox\springfox-swagger2\2.5.0\springfox-swagger2-2.5.0.jar;F:\project\mvn\aliyun\io\swagger\swagger-annotations\1.5.9\swagger-annotations-1.5.9.jar;F:\project\mvn\aliyun\io\swagger\swagger-models\1.5.9\swagger-models-1.5.9.jar;F:\project\mvn\aliyun\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;F:\project\mvn\aliyun\io\springfox\springfox-spi\2.5.0\springfox-spi-2.5.0.jar;F:\project\mvn\aliyun\io\springfox\springfox-core\2.5.0\springfox-core-2.5.0.jar;F:\project\mvn\aliyun\io\springfox\springfox-schema\2.5.0\springfox-schema-2.5.0.jar;F:\project\mvn\aliyun\io\springfox\springfox-swagger-common\2.5.0\springfox-swagger-common-2.5.0.jar;F:\project\mvn\aliyun\io\springfox\springfox-spring-web\2.5.0\springfox-spring-web-2.5.0.jar;F:\project\mvn\aliyun\com\google\guava\guava\18.0\guava-18.0.jar;F:\project\mvn\aliyun\com\fasterxml\classmate\1.4.0\classmate-1.4.0.jar;F:\project\mvn\aliyun\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;F:\project\mvn\aliyun\org\springframework\plugin\spring-plugin-core\1.2.0.RELEASE\spring-plugin-core-1.2.0.RELEASE.jar;F:\project\mvn\aliyun\org\springframework\plugin\spring-plugin-metadata\1.2.0.RELEASE\spring-plugin-metadata-1.2.0.RELEASE.jar;F:\project\mvn\aliyun\org\mapstruct\mapstruct\1.0.0.Final\mapstruct-1.0.0.Final.jar;F:\project\mvn\aliyun\io\springfox\springfox-swagger-ui\2.5.0\springfox-swagger-ui-2.5.0.jar" cn.suncsf.test.sf.mstest.App 16:54:57.808 [main] INFO cn.suncsf.test.sf.mstest.App - 服务启动 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.2.RELEASE) 2019-03-25 16:54:58.664 INFO 12296 --- [ main] cn.suncsf.test.sf.mstest.App : Starting App on WIN-K10T49CH3R9 with PID 12296 (F:\project\sjava\mtest\target\classes started by Administrator in F:\project\sjava\mtest) 2019-03-25 16:54:58.665 INFO 12296 --- [ main] cn.suncsf.test.sf.mstest.App : No active profile set, falling back to default profiles: default 2019-03-25 16:55:00.866 INFO 12296 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$49cd6a0f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-25 16:55:01.487 INFO 12296 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http) 2019-03-25 16:55:01.522 INFO 12296 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-03-25 16:55:01.522 INFO 12296 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14] 2019-03-25 16:55:01.533 INFO 12296 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\Program Files\Java\jdk1.8.0_171\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;D:\Program Files\Microsoft SQL Server\100\Tools\Binn\;D:\Program Files\Microsoft SQL Server\100\DTS\Binn\;D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;D:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;D:\Program Files\Java\jdk1.8.0_171\bin;D:\Program Files\Java\jdk1.8.0_171\jre\bin;D:\Program Files\TortoiseSVN\bin;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;D:\tools\maven3.5\bin;D:\Program Files\nodejs\;D:\Program Files\Python\Python37\Scripts\;D:\Program Files\Python\Python37\;D:\Program Files\JetBrains\IntelliJ IDEA 2018.3.4\bin;;D:\Program Files\Microsoft VS Code\bin;C:\Users\Administrator\AppData\Roaming\npm;.] 2019-03-25 16:55:01.721 INFO 12296 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-03-25 16:55:01.721 INFO 12296 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2970 ms 2019-03-25 16:55:03.225 INFO 12296 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2019-03-25 16:55:03.402 WARN 12296 --- [ main] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration) 2019-03-25 16:55:03.613 INFO 12296 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed 2019-03-25 16:55:03.646 INFO 12296 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s) 2019-03-25 16:55:03.665 INFO 12296 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references 2019-03-25 16:55:03.955 INFO 12296 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path '' 2019-03-25 16:55:03.961 INFO 12296 --- [ main] cn.suncsf.test.sf.mstest.App : Started App in 5.91 seconds (JVM running for 7.365) 2019-03-25 16:55:03.966 INFO 12296 --- [ main] cn.suncsf.test.sf.mstest.App : 启动结束
11、访问 http://localhost:8082/swagger-ui.html
12、填充测试数据并通过接口调用
INSERT INTO `test`.`t_test` (`t_id`, `name`) VALUES ('1', 'Aasd'); INSERT INTO `test`.`t_test` (`t_id`, `name`) VALUES ('2', 'Aasdasda啊啊啊啊asd'); INSERT INTO `test`.`t_test` (`t_id`, `name`) VALUES ('3', 'Aasdasda啊啊是大大啊啊啊asd');
调用数据:
返回结果:
13、具体目录结构
14、源码网盘连接: https://pan.baidu.com/s/1IPShD7vLL-HG3XtyhUprRg 提取码: 86px
至此spring boot + mybatis + swagger集成结束。