SpringBoot启动报:Update your application‘s configuration 服务终止

场景

当时是在测试Jayspt加密配置文件时,自己搭的一个SpringBoot项目,测试连接数据库 正常返回数据。
在添加Jasypt依赖后 启动项目报:

Description:

Failed to bind properties under 'spring.datasource.password' to java.lang.String:

    Reason: Failed to bind properties under 'spring.datasource.password' to java.lang.String

Action:

Update your application's configuration

如图:
在这里插入图片描述当时是自己在Maven仓库中找的最新的版本 3.0.0

解决

检查语法

出问题后 首先检查 Jasypt 语法,没问题。
检查生成密文也没问题

查看pom.xml文件是否引入版本过高

引入Jasypt后启动报错,是不是引入版本过高?
在Maven仓库中找了一个 2.1.2 版本的,启动测试 正常~

总结

遇到 Update your application‘s configuration 检查 pom.xml 的依赖~

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
JavaScript Applications with Node.js, React, React Native and MongoDB: Design, code, test, deploy and manage in Amazon AWS By 作者: Eric Bush ISBN-10 书号: 0997196661 ISBN-13 书号: 9780997196665 出版日期: 2018-07-07 pages 页数: 445 JavaScript Applications with Node.js, React, React Native and MongoDB: Design, code, test, deploy and manage in Amazon AWS JavaScript is more popular than ever. This is due to the huge developer community and it being used in every layer of an application technology stack. This book will teach you how to develop JavaScript applications with simple to use, yet powerful JavaScript technologies and host everything in the cloud in an economic and robust way in AWS. Enjoy an all-encompassing presentation of theory, reference and implementation for building three-tier architectures with a Data Layer (MongoDB), Service Layer (Node.js/Express) and Presentation Layer (React/React Native). Learn how to architect, develop, test, secure, deploy and manage a RESTful Web Service. Contents Preface About the Author Introduction PART I: The Data Laver(MongoDB) Chapter 1: Fundamentals 1.1Definition of the Data Layer 1.2 Data layer design process 1.3Introducing MongoDB 1.4The MongoDB Collection 1.5The MongoDB Document Chapter2: Data Modeling 2.1 Referencing or Embedding Data 2.2When to use Referencing 2.3 Reference Relationship Patterns 2.4AHybrid Approach 2.5 Differentiating Document Types 2.6Running Out of Space in a Database 2.7 Access Control Chapter 3: Querving for Documents 3.1Query Criteria 3-2Proiection criteria 3.3 Querving Polymorphic Documents in a Single Collection Chapter 4: Updating Documents 4.1Update operators 4.2Array Update Operators 4.3Transactions Chapter 5: Managing Availability and Performance 5.1Indexing 5.2Availability through Replication 5.3 Sharding Chapter 6: NewsWatcher App Development 6.1 Create the Database and Collection 6.2 Data Model Document Design 6.3Trving Out Some Queries 5.4Indexing Policy 6.5Moving On Chapter 7: DevOps for MongoDB
根据错信息,可以看出问题出在将拦截器类注册为 Bean 后,将其添加到 MyBatis 的拦截器列表中时出现了类型转换问题。具体来说,Spring Framework 将拦截器类的类名作为字符串添加到了 `mybatis.configuration.interceptors[0]` 属性中,而 MyBatis 在读取该属性时期望得到 `org.apache.ibatis.plugin.Interceptor` 类型的对象。 解决这个问题的方法是,将拦截器类的实例注入到 `SqlSessionFactory` 中,在创建 `SqlSessionFactory` 时将其添加到 MyBatis 的拦截器列表中。具体的代码如下: ```java @Configuration public class MyBatisConfig { @Autowired private SqlStatsInterceptor sqlStatsInterceptor; @Bean public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource); // 注册拦截器 Interceptor[] interceptors = { sqlStatsInterceptor }; sessionFactory.setPlugins(interceptors); return sessionFactory.getObject(); } } ``` 在这段代码中,我们将 `SqlStatsInterceptor` 类的实例 `sqlStatsInterceptor` 注入到 `MyBatisConfig` 配置类中,并在创建 `SqlSessionFactory` 时将其添加到 MyBatis 的拦截器列表中。 注意,我们使用了 `SqlSessionFactoryBean` 类而不是 `SqlSessionFactory` 类来创建 `SqlSessionFactory` 。这是因为 `SqlSessionFactoryBean` 类可以方便地支持 Spring Framework 的自动配置和依赖注入机制,而 `SqlSessionFactory` 类则不支持。 另外,如果你的应用程序使用的是 MyBatis 3.5.0 及以上版本,你也可以使用 MyBatis 提供的 `@Interceptors` 注解来将拦截器类注册到 MyBatis 中,这样就可以避免使用 `SqlSessionFactory` 和 `SqlSessionFactoryBean` 。具体的代码如下: ```java @Intercepts({@Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})}) @Component public class SqlStatsInterceptor implements Interceptor { // 拦截器逻辑代码 } @Configuration public class MyBatisConfig { @Autowired private SqlStatsInterceptor sqlStatsInterceptor; @Bean public Configuration mybatisConfig() { Configuration config = new Configuration(); // 注册拦截器 config.addInterceptor(sqlStatsInterceptor); return config; } } ``` 在这段代码中,我们使用了 `Configuration` 类来创建 MyBatis 的配置对象,并使用 `addInterceptor` 方法将拦截器类的实例 `sqlStatsInterceptor` 添加到 MyBatis 的拦截器列表中。这样,当 MyBatis 创建 `SqlSession` 时,就会自动应用该拦截器。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Windyº

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值