在勾选相关组件后,

pom.xml文件上发生了根本的变化

1、这是最简单的项目的pom文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5.  
  6. <groupId>com.example</groupId>
  7. <artifactId>demo</artifactId>
  8. <version>0.0.1-SNAPSHOT</version>
  9. <packaging>jar</packaging>
  10.  
  11. <name>demo</name>
  12. <description>Demo project for Spring Boot</description>
  13.  
  14. <parent>
  15. <groupId>org.springframework.boot</groupId>
  16. <artifactId>spring-boot-starter-parent</artifactId>
  17. <version>2.0.2.RELEASE</version>
  18. <relativePath/> <!-- lookup parent from repository -->
  19. </parent>
  20.  
  21. <properties>
  22. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  23. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  24. <java.version>1.8</java.version>
  25. </properties>
  26.  
  27. <dependencies>
  28. <dependency>
  29. <groupId>org.springframework.boot</groupId>
  30. <artifactId>spring-boot-starter</artifactId>
  31. </dependency>
  32.  
  33. <dependency>
  34. <groupId>org.springframework.boot</groupId>
  35. <artifactId>spring-boot-starter-test</artifactId>
  36. <scope>test</scope>
  37. </dependency>
  38. </dependencies>
  39.  
  40. <build>
  41. <plugins>
  42. <plugin>
  43. <groupId>org.springframework.boot</groupId>
  44. <artifactId>spring-boot-maven-plugin</artifactId>
  45. </plugin>
  46. </plugins>
  47. </build>
  48.  
  49. </project>

pom.xml

这是勾选了web、mongodb、mybatis、redis等的项目的pom文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5.  
  6. <groupId>com.xxxxxx.spiderplatform</groupId>
  7. <artifactId>spidercontroller</artifactId>
  8. <version>0.0.1-SNAPSHOT</version>
  9. <packaging>jar</packaging>
  10.  
  11. <name>spidercontroller</name>
  12. <description>content supportor</description>
  13.  
  14. <parent>
  15. <groupId>org.springframework.boot</groupId>
  16. <artifactId>spring-boot-starter-parent</artifactId>
  17. <version>2.0.2.RELEASE</version>
  18. <relativePath/> <!-- lookup parent from repository -->
  19. </parent>
  20.  
  21. <properties>
  22. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  23. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  24. <java.version>1.8</java.version>
  25. </properties>
  26.  
  27. <dependencies>
  28. <dependency>
  29. <groupId>org.springframework.boot</groupId>
  30. <artifactId>spring-boot-starter-cache</artifactId>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.springframework.boot</groupId>
  34. <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.springframework.boot</groupId>
  38. <artifactId>spring-boot-starter-data-mongodb</artifactId>
  39. </dependency>
  40. <dependency>
  41. <groupId>org.springframework.boot</groupId>
  42. <artifactId>spring-boot-starter-data-redis</artifactId>
  43. </dependency>
  44. <dependency>
  45. <groupId>org.springframework.boot</groupId>
  46. <artifactId>spring-boot-starter-security</artifactId>
  47. </dependency>
  48. <dependency>
  49. <groupId>org.springframework.boot</groupId>
  50. <artifactId>spring-boot-starter-web</artifactId>
  51. </dependency>
  52. <dependency>
  53. <groupId>org.mybatis.spring.boot</groupId>
  54. <artifactId>mybatis-spring-boot-starter</artifactId>
  55. <version>1.3.2</version>
  56. </dependency>
  57.  
  58. <dependency>
  59. <groupId>org.springframework.boot</groupId>
  60. <artifactId>spring-boot-devtools</artifactId>
  61. <scope>runtime</scope>
  62. </dependency>
  63. <dependency>
  64. <groupId>mysql</groupId>
  65. <artifactId>mysql-connector-java</artifactId>
  66. <scope>runtime</scope>
  67. </dependency>
  68. <dependency>
  69. <groupId>org.projectlombok</groupId>
  70. <artifactId>lombok</artifactId>
  71. <optional>true</optional>
  72. </dependency>
  73. <dependency>
  74. <groupId>org.springframework.boot</groupId>
  75. <artifactId>spring-boot-starter-test</artifactId>
  76. <scope>test</scope>
  77. </dependency>
  78. <dependency>
  79. <groupId>org.springframework.security</groupId>
  80. <artifactId>spring-security-test</artifactId>
  81. <scope>test</scope>
  82. </dependency>
  83. </dependencies>
  84.  
  85. <build>
  86. <plugins>
  87. <plugin>
  88. <groupId>org.springframework.boot</groupId>
  89. <artifactId>spring-boot-maven-plugin</artifactId>
  90. </plugin>
  91. </plugins>
  92. </build>
  93.  
  94. </project>

pom.xml

对比两个pom文件,会发现,勾选组建后的项目在dependencies中内容有了主要添加

然后运行添加组建后的文件,会报错:

  1. Description:
  2.  
  3. Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
  4. //无法配置数据库,没有指定url属性,并且无法配置embedded datasource
  5. Reason: Failed to determine a suitable driver class
  6. //原因:无法明确指定正确的驱动类(driver.class)
  7.  
  8. Action:
  9.  
  10. Consider the following:
  11. If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
  12. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
  13.  
  14. //建议:
  15. //如果如果需要加载嵌入式的数据库,请将他放入路径中
  16. //如果有数据库设置需要从指定配置文件中加载,需要调用该配置文件(目前没有活动的配置文件)

分析:

通过比较两个项目结构,和修改的文件,会发现只因为有pom文件的修改导致项目中增加的mysql、redis、es、mongodb的依赖包的导入,需要添加新的database配置文件,可能因为springboot的启动会自动加载这些依赖启动时候需要的以来文件。

结果:

报错的原因是因为导入的两个依赖

  1. <!--<dependency>-->
  2. <!--<groupId>org.springframework.boot</groupId>-->
  3. <!--<artifactId>spring-boot-starter-web</artifactId>-->
  4. <!--</dependency>-->
  5.  
  6. <!--<dependency>-->
  7. <!--<groupId>org.mybatis.spring.boot</groupId>-->
  8. <!--<artifactId>mybatis-spring-boot-starter</artifactId>-->
  9. <!--<version>1.3.2</version>-->
  10. <!--</dependency>-->

这两个依赖的导入需要有他们支持的相关的配置文件

web 、 mybatis

Spring Boot相关组件的添加的更多相关文章

  1. spring boot 四大组件之Starter

    1.概述 依赖管理是任何复杂项目的关键方面.手动完成这些操作并不理想; 你花在它上面的时间越多,你在项目的其他重要方面所花费的时间就越少. 构建Spring Boot启动器是为了解决这个问题.Star ...

  2. 【面试 spring boot】【第十七篇】spring boot相关面试

    spring boot相关面试 ====================================================== 1.spring boot启动类  启动原理 参考:htt ...

  3. 回顾maven项目的spring boot相关知识点

    2021新年快乐! 在参加完研究生考试后,感觉像是放下了一个大负担,但并不能就此以为什么都结束了.反而,当我今天去看了一下之前老师带领我们班级做的一个maven项目,感觉像是第一次看到这个,十分陌生. ...

  4. Spring Boot 2.X 如何添加拦截器?

    最近使用SpringBoot2.X搭建了一个项目,大部分接口都需要做登录校验,所以打算使用注解+拦截器来实现,在此记录下实现过程. 一.实现原理 1. 自定义一个注解@NeedLogin,如果接口需要 ...

  5. spring boot 四大组件之Auto Configuration

    SpringBoot 自动配置主要通过 @EnableAutoConfiguration, @Conditional, @EnableConfigurationProperties 或者 @Confi ...

  6. spring boot 四大组件之Actuator

    执行器(Actuator)的定义 执行器是一个制造业术语,指的是用于移动或控制东西的一个机械装置,一个很小的改变就能让执行器产生大量的运动.An actuator is a manufacturing ...

  7. Spring Boot 自动扫描组件

    使用@ComponentScan自动扫描组件 案例准备 1.创建一个配置类,在配置类上添加 @ComponentScan 注解.该注解默认会扫描该类所在的包下所有的配置类,相当于之前的 <con ...

  8. 集成 Spring Boot 常用组件的后台快速开发框架 spring-boot-plus 国

    spring-boot-plus是一套集成spring boot常用开发组件的后台快速开发框架 Purpose 每个人都可以独立.快速.高效地开发项目! Everyone can develop pr ...

  9. Spring Boot相关~

    Introducing Spring Boot Spring Boot makes it easy to create stand-alone, production-grade Spring-bas ...

随机推荐

  1. unreal3控制台窗口属性调整

    在windows平台上,unreal3的console窗口类是FOutputDeviceConsoleWindows 启动时,它可以从XXXGame.ini中读取诸如窗口大小之类的属性,具体的代码在 ...

  2. 1.浅谈XXE漏洞攻击与防御

    XML基础 在介绍XXE漏洞前,先学习温顾一下XML的基础知识.XML被设计为传输和存储数据,其焦点是数据的内容,其把数据从HTML分离,是独立于软件和硬件的信息传输工具. XML是一种用于标记电子文 ...

  3. position:fixed;如何居中

    div{ position:fixed; margin:auto; left:; right:; top:; bottom:; width:100px; height:100px; } 如果只需要左右 ...

  4. oracle环境变量

    1---此部分引自http://hi.baidu.com/jason_xux/item/1f44681d356927fa756a8480  感谢 ORA_NLS33 环境变量ora_nls33定义'l ...

  5. 关于pacemaker监控mysql修复的方法

    对工作中,涉及到数据库修复的一个简单汇总 1.在所有的控制节点上,执行pcs resource命令行,查看控制节点上pacemaker的状态是否异常,如果异常,通过crm_resource -P命令行 ...

  6. X-Content-Type-Options和 X-XSS-Protection

    X-Content-Type-Options 互联网上的资源有各种类型,通常浏览器会根据响应头的Content-Type字段来分辨它们的类型.例如:"text/html"代表htm ...

  7. luogu3224 永无乡(动态开点,权值线段树合并)

    luogu3224 永无乡(动态开点,权值线段树合并) 永无乡包含 n 座岛,编号从 1 到 n ,每座岛都有自己的独一无二的重要度,按照重要度可以将这 n 座岛排名,名次用 1 到 n 来表示.某些 ...

  8. 20165224 陆艺杰 Exp7 网络欺诈防范

    通常在什么场景下容易受到DNS spoof攻击 一样的局域网环境下 在日常生活工作中如何防范以上两攻击方法 使用攻击检查工具 简单应用SET工具建立冒名网站  打开 apache服务 apache 是 ...

  9. React方法论

    按照目前学习进度不定更新 react渲染的效率,看起来是全体的渲染,其实react在虚拟dom上的处理简直完美.它会过滤掉那些原来就有的东西,不去全体地重复渲染一遍. 即将进入实战,React至今的个 ...

  10. Knight Tournament (set)

    Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the me ...