spring boot2 + mybatis + elasticsearch + mysql 整合(1)——项目搭建与测试

资料查找说明

田守枝java技术博客:http://www.tianshouzhi.com/api/tutorials/springboot/101

fantasic_van的博客:https://blog.csdn.net/fantasic_van/article/details/79309665

天涯泪小武的博客:https://blog.csdn.net/tianyaleixiaowu/article/details/72833940

Spring Data Elasticsearch:

https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#project

小盒子的博客:https://blog.csdn.net/m0_37044606/article/details/79793125

官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html    

 

1  项目搭建

1.1  新建spring boot的elasticsearch项目

       用STS新建,勾选JDBC、Mybatis、Web、Mysql、nosql里的elasticsearch选项,等待创建完成即可。

        

创建完成后,查看项目架构如下:

 

1.2  热加载(部署)

       在SpringBoot1.3.1之后,devtools已经正式发布到Maven中央仓库,只要进行如下配置即可:

1.3  配置yml文件

2  测试

       测试的工程目录如下:

2.1  写一个自己的Controller测试

    @RestController
    public class TestController {
        @RequestMapping("/hello")
        public String test(){
            return "hello world!";  
        }
    }

2.2  运行spring-boot的入口文件EsDemoApplication.java

       出现问题如下:

    Description:
    Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.
    Reason: Failed to determine a suitable driver class
    Action:
    Consider the following:
        If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
        If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

PS:启用springboot的自动配置,但是又没找到properties中spring.datasource.url属性。

       问题解决:http://www.fuzhicode.com/blog/article/104.html

    @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
    public class EsDemoApplication {
        public static void main(String[] args) {
            SpringApplication.run(EsDemoApplication.class, args);
        }
    }

启动成功截图:

 

2.3  浏览器访问

 

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值