发表于: 2019-10-12 11:23:12

0 808


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin)

先解决昨天的问题。

已经启动前台service,但是前台web还是不行。

Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class


Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


只有一个jpa的依赖,将它注释。

没有扫描到mapper包下的xml文件

spring boot会默认加载org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration类使用了@Configuration注解向spring注入了dataSource bean,因为工程中没有关于dataSource相关的配置信息,当spring创建dataSource bean因缺少相关的信息就会报错

因此我们需要在Application类上面增加注解

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

其原因为数据源没有加载进来

在网上查找方法大多数都是讲要添加以下注解

exclude= {DataSourceAutoConfiguration.class}

最后问了一下别的院的师兄,是因为分页插件,导致web客户端要配置相关的数据源。,将service的数据源复制到web。

server.port=20852

spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/academy-qiuligao?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
spring.datasource.username=author
spring.datasource.password=author
#本地测试
#spring.datasource.username=root
#spring.datasource.password=0000
#spring.datasource.username=root
#spring.datasource.password=123456

#字符编码
spring.http.encoding.enabled=true
spring.http.encoding.charset=utf-8
#使用强制编码,必须将请求编成utf-8
spring.http.encoding.force=true


#单个文件上传大小
spring.servlet.multipart.max-file-size=200MB
#多文件上传总大小
spring.servlet.multipart.max-request-size=200MB

#dubbo配置
dubbo.application.name=academy_home_web_qiuligao
dubbo.registry.address=127.0.0.1:2181
dubbo.registry.protocol=zookeeper
dubbo.monitor.protocol=registry
dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
dubbo.protocol.name=dubbo
dubbo.protocol.port=20856


开始后台消息接口。


后台消息-消息列表

后台消息列表,和前台差不多。

 更简单,直接搜索meesage表。

接口运行报500.

发现没有标注解,service上面标上@Service            

实现序列化。

ok,成功;


后台消息-搜索

学习mybatis生成的内容:

mybatis 之数据库 include refid ="base_column_list"

1、首先定义一个sql标签,一定要定义唯一id

<sql id="Base_Column_List" >

字段名1,字段名2

</sql>
2、然后通过id引用
<select id="selectAll">
select
<include refid="Base_Column_List" />
    from 表名
</select>

这时<include refid="Base_Column_List" />会自动把上面的代码贴过来。

数据库中查询的语句就可以解析为:select 字段名1,字段名2  from 表名





后台消息-删除

后台消息-查看

后台消息-立即推送

后台消息-新增消息提交

后台消息-新增消息





明天计划的事情:(一定要写非常细致的内容)
遇到的问题:(遇到什么困难,怎么解决的)
收获:(通过今天的学习,学到了什么知识)


返回列表 返回列表
评论

    分享到