spring boot项目搭建中遇到的问题

  自己动手搭建一下spring boot的项目,中途遇到了几个问题,在这里记录一下!

一、关于数据库中的表设计的问题

1、设计表的时候一定要添加的两个字段created updated 创建时间与更新时间 这两个字段是必须的
2、数据库的表字段设计一定要规范,因为如果使用分页助手的话,你的表字段设计不规范,会存在很多问题
比如:我的book_info 表中的字段 有一个是pubInfo 驼峰命名法,但是其他的是book_name、img_url 下划线命名法,造成使用通用mapper以及分页助手的时候,会造成找不到pub_info
这一列,我猜可能他的插件的内部是使用的下划线命名法的字段吧,这种东西一定要在设计之前考虑到,规范的是使用下划线那种命名的方法
...这个是可以自己设置的。在实体类中用注解的方式来设置table的名称以及column的名称,害得我重新设计了一张表,不过,最好约束自己遵守规范

3、设计数据库表的字段的时候一定要设置字符集,最好就是通用的utf-8,避免以后数据插入数据库的时候出现乱码的问题

二、项目搭建中问题

集成一下通用mapper以及分页助手以及数据池,优化一下数据库连接访问,通用mapper以及分页助手可以简化很多代码,提高开发效率

1、分页助手的版本问题

正确的maven中的依赖各个版本号:

 1     <!--通用mapper -->
 2     <dependency>
 3         <groupId>tk.mybatis</groupId>
 4         <artifactId>mapper-spring-boot-starter</artifactId>
 5         <version>1.1.0</version>
 6     </dependency>
 7     <!--pagehelper分页助手 -->
 8     <dependency>
 9         <groupId>com.github.pagehelper</groupId>
10         <artifactId>pagehelper-spring-boot-starter</artifactId>
11         <version>1.2.10</version>
12     </dependency>
13     <!--阿里巴巴数据源 -->
14     <dependency>
15         <groupId>com.alibaba</groupId>
16         <artifactId>druid</artifactId>
17         <version>1.0.25</version>
18     </dependency>

这里面需要注意的是分页助手,这个之前用的是1.1.0,但是和最新的2.1.7的springboot整合的时候回报错,重现了一下错误信息:

 1 org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration‘: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration] from ClassLoader [[email protected]]
 2     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:570)
 3     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
 4     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
 5     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 6     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
 7     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
 8     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
 9     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
10     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
11     at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
12     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
13     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
14     at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
15     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
16     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
17     at com.example.demo.web.DemoWebApplication.main(DemoWebApplication.java:18)
18 Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration] from ClassLoader [[email protected]]
19     at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:760)
20     at org.springframework.util.ReflectionUtils.doWithLocalFields(ReflectionUtils.java:692)
21     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.buildResourceMetadata(CommonAnnotationBeanPostProcessor.java:365)
22     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.findResourceMetadata(CommonAnnotationBeanPostProcessor.java:350)
23     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(CommonAnnotationBeanPostProcessor.java:298)
24     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1077)
25     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:567)
26     ... 15 common frames omitted
27 Caused by: java.lang.NoClassDefFoundError: Lorg/springframework/boot/bind/RelaxedPropertyResolver;
28     at java.lang.Class.getDeclaredFields0(Native Method)
29     at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
30     at java.lang.Class.getDeclaredFields(Class.java:1916)
31     at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:755)
32     ... 21 common frames omitted
33 Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver
34     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
35     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
36     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
37     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
38     ... 25 common frames omitted

看这个错误信息好像是和AppClassLoader有关的,类加载器加载不到所需要的RelaxedPropertyResolver类,具体内部是怎么解决这个问题的,也不知道,通过网上求救是换jar的版本换成1.2.10的版本就OK了

2、application.properties文件中的配置中的问题

这里的问题主要是通用mapper的问题:先看一下正确的配置

1 # 通用mapper配置
2 mapper.mappers=com.example.demo.dao.BaseMapper
3 mapper.not-empty=false
4 mapper.identity=MYSQL

这里面有一个配置需要注意:mapper.mappers 这个配置,这个配置是需要配置你写的那个基础的mapper类的全路径的BaseMapper的代码:

1 /**
2  * @program: demo
3  * @description: 基础的mapper
4  * @author: ssc
5  * @create: 2019/8/20 10:21
6  **/
7 public interface BaseMapper<T> extends Mapper<T>,MySqlMapper<T>{
8
9 }

这个如果没有配置正确的话,启动的时候也会报错的,具体的报错信息:

1 Description:
2 Failed to bind properties under ‘mapper.mappers‘ to java.util.List<java.lang.Class<?>>:
3     Reason: No converter found capable of converting from type [java.lang.String] to type [java.util.List<java.lang.Class<?>>]

补充一下:这里还有一个问题,就是BaseMapper能和业务中的mapper类放到一个包中的问题,这个还没有验证,反正现在是不放到一个包中是没有问题的

TODO:这个明天验证一下
2019年8月21日09:46:30 今天来验证一下这个,这个好像是不行的,因为在启动类中加入了@MapperScan("com.example.demo.dao.mapper")注解,不能让启动类扫描到这个BaseMapper不能放到和@MapperScan注解的同一个包下面,不然会报错,创建失败

 1 org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘com.github.pagehelper.autoconfigure.MapperAutoConfiguration‘: Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
 2     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:139)
 3     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:414)
 4     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770)
 5     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
 6     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
 7     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
 8     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 9     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
10     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
11     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
12     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
13     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
14     at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
15     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
16     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
17     at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
18     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
19     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
20     at com.example.demo.web.DemoWebApplication.main(DemoWebApplication.java:18)
21 Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
22     at tk.mybatis.mapper.mapperhelper.MapperHelper.setSqlSource(MapperHelper.java:247)
23     at tk.mybatis.mapper.mapperhelper.MapperHelper.processConfiguration(MapperHelper.java:310)
24     at tk.mybatis.mapper.mapperhelper.MapperHelper.processConfiguration(MapperHelper.java:289)
25     at com.github.pagehelper.autoconfigure.MapperAutoConfiguration.addPageInterceptor(MapperAutoConfiguration.java:69)
26     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
27     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
28     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
29     at java.lang.reflect.Method.invoke(Method.java:498)
30     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:363)
31     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:307)
32     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
33     ... 18 common frames omitted
34 Caused by: java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
35     at tk.mybatis.mapper.mapperhelper.MapperTemplate.setSqlSource(MapperTemplate.java:246)
36     at tk.mybatis.mapper.mapperhelper.MapperHelper.setSqlSource(MapperHelper.java:244)
37     ... 28 common frames omitted
38 Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
39     at tk.mybatis.mapper.mapperhelper.MapperTemplate.getEntityClass(MapperTemplate.java:278)
40     at tk.mybatis.mapper.provider.base.BaseSelectProvider.selectCount(BaseSelectProvider.java:111)
41     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
42     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
43     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
44     at java.lang.reflect.Method.invoke(Method.java:498)
45     at tk.mybatis.mapper.mapperhelper.MapperTemplate.setSqlSource(MapperTemplate.java:234)
46     ... 29 common frames omitted

3、实体类与数据库表对应的问题

这个就是一些字段与实体类的属性,以及表名称与类名称的对应的问题了,这个也是很恶心的,还是不是很熟悉,所以总是报错,在创建实体类的时候,最好在类名上加上@Table(name="表名称")以及在属性上加上@Column(name="字段名称")这样的注解,以防范出现对应错误

4、BaseService封装的问题

先看一下错误信息:

 1 org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘bookController‘: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘bookService‘: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘tk.mybatis.mapper.common.Mapper<?>‘ available: expected single matching bean but found 2: bookInfoMapper,bookMapper
 2     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324)
 3     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
 4     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
 5     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
 6     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
 7     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 8     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
 9     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
10     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
11     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
12     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
13     at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
14     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743)
15     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390)
16     at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
17     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214)
18     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203)
19     at com.example.demo.web.DemoWebApplication.main(DemoWebApplication.java:18)
20 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘bookService‘: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘tk.mybatis.mapper.common.Mapper<?>‘ available: expected single matching bean but found 2: bookInfoMapper,bookMapper
21     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324)
22     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
23     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
24     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
25     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
26     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
27     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
28     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
29     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeanByName(AbstractAutowireCapableBeanFactory.java:452)
30     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:526)
31     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
32     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:636)
33     at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
34     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
35     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:321)
36     ... 17 common frames omitted
37 Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘tk.mybatis.mapper.common.Mapper<?>‘ available: expected single matching bean but found 2: bookInfoMapper,bookMapper
38     at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:221)
39     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1229)
40     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
41     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:520)
42     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
43     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:636)
44     at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
45     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
46     at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:321)
47     ... 31 common frames omitted

这个错误的根本原因是在封装的通用的service中,因为也就是BaseService这个类,开始写的是使用的
@Autowired
private Mapper<T> mapper;

为啥这样写就会出现那个错误呢 ?分析一下可以知道,当一个新创建的service层的类继承BaseService的时候,BaseService需要自动注入Mapper类,但是这时候Mapper发现spring容器中有多个类实现了Mapper,到底是用哪一个实现类呢,他自己搞不清楚,于是就抛出异常了,找到了多个实现类,现在记不清之前如何解决这个问题的,但是可以退一步,不要在BaseService中自动注入Mapper类我就明确告诉你,你需要实现那个Mapper类型的class。

具体的解决方法是:

我创建一个抽象的方法,子类继承我的时候需要给我一个具体的实现类
public abstract Mapper<T> getMapper();

例如:子类BookService 直接把你实现的BookMapper给了父类就行了,这样就不会有那个,不知道实现哪个子类的情况了:

 1 @Service
 2 public class BookService extends BaseService<BookInfo>{
 3
 4     private Logger logger = LoggerFactory.getLogger(BookService.class);
 5
 6     @Autowired
 7     private BookMapper bookMapper;
 8
 9     @Override
10     public Mapper<BookInfo> getMapper() {
11         return bookMapper;
12     }
13 }

原文地址:https://www.cnblogs.com/ssh-html/p/11407034.html

时间: 2024-11-06 19:56:41

spring boot项目搭建中遇到的问题的相关文章

Spring Boot项目搭建

1.Spring Boot概述 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置.总所周知,Spring平台饱受非议的一点就是大量的XML配置以及复杂的依赖管理,而Spring Boot的出现就是用来简化操作的.相比传统的Spring,项目搭建更简单.方便.快速. 2.项目搭建 本文采用IDEA搭建Spring Boot,Demo结构图如下: 通过ID

[读书笔记] 一、Spring boot项目搭建与配置文件

读书笔记:[JavaEE开发的颠覆者 Spring Boot实战] 作者:汪云飞 从今天开始坚持读书,并记录下此读书笔记. 一,初接触 Spring boot 项目Hello world搭建 1.pom.xml 配置如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocat

Spring Boot项目搭建(Spring Boot 2.2.4 + MyBatis + MySql)

创建Spring Boot项目 1.New Project 2)取名为sb2 (springboot2.x) 3.勾选Spring Web 4.勾选MyBatis framework 5.下一步,然后点击完成 6.pom.xml增加jar和插件 jar dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1

spring boot项目开发中遇到问题,持续更新

1.JPA中EntityManager不能执行建表语句,提示要加事务Error:javax.persistence.TransactionRequiredException: Executing an update/delete query 换成直接连数据库原来操作来解决 2.resources下的文件采用中文命名,读取不到. 3.使用h2数据库在加了认证后不能访问h2后台,登录进去为空白f12看到页面有一个错误提示Sorry, Lynx not supported yet  解决方法: 在安全

Gitlab CI 集成 Kubernetes 集群部署 Spring Boot 项目

在上一篇博客中,我们成功将 Gitlab CI 部署到了 Docker 中去,成功创建了 Gitlab CI Pipline 来执行 CI/CD 任务.那么这篇文章我们更进一步,将它集成到 K8s 集群中去.这个才是我们最终的目标.众所周知,k8s 是目前最火的容器编排项目,很多公司都使用它来构建和管理自己容器集群,可以用来做机器学习训练以及 DevOps 等一系列的事情. 在这里,我们聚焦 CI/CD,针对于 Spring Boot 项目,借助 Gitlab CI 完成流水线的任务配置,最终部

在Spring Boot项目中使用Redis集群

Redis安装 Mac 系统安装Redis brew方式安装 在命令汗执行命令 brew install redis 安装完成之后的提示信息 ==> Downloading https://homebrew.bintray.com/bottles/redis-5.0.2.mojave.bottle.tar.gz ######################################################################## 100.0% ==> Pouring

Spring Boot 项目实战(一)Maven 多模块项目搭建

Maven父项目 以SpringBoot项目为例https://blog.csdn.net/weixin_30606669/article/details/99478544 Maven 多模块父子工程 (含Spring Boot示例)https://www.cnblogs.com/meitanzai/p/10945085.html https://www.cnblogs.com/orzlin/p/10330163.html 一.前言 最近公司项目准备开始重构,框架选定为 Spring Boot

Eclipse中创建新的Spring Boot项目

简单几步,在Eclipse中创建一个新的Spring Boot项目: 1.Eclipse中安装STS插件: Help -> Eclipse Marketplace... Search或选择"Popular"标签,选择Spring Tool Suite (STS) for Eclipse插件,安装: 2.New -> Project... 找到Spring目录,选择Spring Starter Project,Next 3.填写跟项目相关的各种信息,然后Next: 4.选择需

【Spring Boot】Spring Boot项目设置多个配置文件,并在生产环境中的Tomcat设置对应的配置文件

1.修改Spring Boot项目配置文件 除了主配置文件,另外创建2个配置文件,注意命名要用application-*.properties 主配置文件中写入,使用dev作为开发配置 spring.profiles.active=dev 2.设置服务器中Tomcat参数,调用生产环境配置 打开Tomcat配置软件 增加配置-Dspring.profiles.active="pro" 重新启动Tomcat即可 原文地址:https://www.cnblogs.com/LiveYourL