当前位置:   article > 正文

慕课网_SpringBoot构建电商基础秒杀项目_学习笔记<2>引入SpingBoot项目

慕课网_SpringBoot构建电商基础秒杀项目_学习笔记<2>引入SpingBoot项目

正题

本项目使用的环境

  • 开发工具:IntelliJ IDEA 2017.3.1,Navicat for MySQL
  • springboot:2.0.5
  • jdk:jdk1.8.0_151
  • maven:apache-maven-3.6.0

步骤:

1.建议多去看看spring的文档

2.设置pom.xml,引入依赖和插件(SpringBoot,mysqldriver,druid连接池,mybatis.spring.boot等依赖十分方便)

  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. <groupId>com.miaoshaproject</groupId>
  6. <artifactId>miaosha</artifactId>
  7. <version>1.0-SNAPSHOT</version>
  8. <name>miaosha</name>
  9. <!-- FIXME change it to the project's website -->
  10. <url>http://www.example.com</url>
  11. <parent>
  12. <groupId>org.springframework.boot</groupId>
  13. <artifactId>spring-boot-starter-parent</artifactId>
  14. <version>2.0.5.RELEASE</version>
  15. </parent>
  16. <properties>
  17. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  18. <maven.compiler.source>1.7</maven.compiler.source>
  19. <maven.compiler.target>1.7</maven.compiler.target>
  20. </properties>
  21. <dependencies>
  22. <dependency>
  23. <groupId>mysql</groupId>
  24. <artifactId>mysql-connector-java</artifactId>
  25. <version>5.1.41</version>
  26. </dependency>
  27. <dependency>
  28. <groupId>com.alibaba</groupId>
  29. <artifactId>druid</artifactId>
  30. <version>1.1.3</version>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.mybatis.spring.boot</groupId>
  34. <artifactId>mybatis-spring-boot-starter</artifactId>
  35. <version>1.3.1</version>
  36. </dependency>
  37. <dependency>
  38. <groupId>junit</groupId>
  39. <artifactId>junit</artifactId>
  40. <version>4.11</version>
  41. <scope>test</scope>
  42. </dependency>
  43. <dependency>
  44. <groupId>org.springframework.boot</groupId>
  45. <artifactId>spring-boot-starter-web</artifactId>
  46. </dependency>
  47. </dependencies>
  48. <build>
  49. <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
  50. <plugins>
  51. <plugin>
  52. <groupId>org.mybatis.generator</groupId>
  53. <artifactId>mybatis-generator-maven-plugin</artifactId>
  54. <version>1.3.5</version>
  55. <dependencies>
  56. <dependency>
  57. <groupId>org.mybatis.generator</groupId>
  58. <artifactId>mybatis-generator-core</artifactId>
  59. <version>1.3.5</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>mysql</groupId>
  63. <artifactId>mysql-connector-java</artifactId>
  64. <version>5.1.41</version>
  65. </dependency>
  66. </dependencies>
  67. <executions>
  68. <execution>
  69. <id>mybatis generator</id>
  70. <phase>package</phase>
  71. <goals><goal>generate</goal></goals>
  72. </execution>
  73. </executions>
  74. <configuration>
  75. <verbose>true</verbose>
  76. <overwrite>true</overwrite>
  77. <configurationFile>
  78. src/main/resources/mybatis-generator.xml
  79. </configurationFile>
  80. </configuration>
  81. </plugin>
  82. <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
  83. <plugin>
  84. <artifactId>maven-clean-plugin</artifactId>
  85. <version>3.1.0</version>
  86. </plugin>
  87. <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
  88. <plugin>
  89. <artifactId>maven-resources-plugin</artifactId>
  90. <version>3.0.2</version>
  91. </plugin>
  92. <plugin>
  93. <artifactId>maven-compiler-plugin</artifactId>
  94. <version>3.8.0</version>
  95. </plugin>
  96. <plugin>
  97. <artifactId>maven-surefire-plugin</artifactId>
  98. <version>2.22.1</version>
  99. </plugin>
  100. <plugin>
  101. <artifactId>maven-jar-plugin</artifactId>
  102. <version>3.0.2</version>
  103. </plugin>
  104. <plugin>
  105. <artifactId>maven-install-plugin</artifactId>
  106. <version>2.5.2</version>
  107. </plugin>
  108. <plugin>
  109. <artifactId>maven-deploy-plugin</artifactId>
  110. <version>2.8.2</version>
  111. </plugin>
  112. <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
  113. <plugin>
  114. <artifactId>maven-site-plugin</artifactId>
  115. <version>3.7.1</version>
  116. </plugin>
  117. <plugin>
  118. <artifactId>maven-project-info-reports-plugin</artifactId>
  119. <version>3.0.0</version>
  120. </plugin>
  121. </plugins>
  122. </pluginManagement>
  123. </build>
  124. </project>

3.在启动类APP.java中设置基于springboot的自动化配置

内嵌tomcat容器就能启动了.

4.可以再写个测试

用浏览器打开localhost:8080就可以看到

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/143811
推荐阅读
相关标签
  

闽ICP备14008679号