springcloud学习-01 建父工程+idea设置(自己看的)【周阳springcloud2020学习笔记】
程序员文章站
2024-03-22 18:33:34
...
约定 > 配置 > 编码
开发步骤(实用)
1)建module
2)改pom
3)写yml
4)主启动
5)业务类
idea设置
- 改字符编码 setting->editor->File Encodeing 全部修改成UTF-8
- 注解生效** setting->build…->compiler->annotation…->右侧 enable 勾上
- java编辑版本 setting->build…->compiler->java compliler 选1.8
- File Types过滤 setting->editor->File Types
.hprof;.idea;.iml;.pyc;.pyo;.rbc;.yarb;~;.DS_Store;.git;.hg;.svn;CVS;pycache;_svn;vssver.scc;vssver2.scc;
1.新建maven项目:demo2020
2.改pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.chen.demo</groupId>
<artifactId>demo2020</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- pom父工程 -->
<packaging>pom</packaging>
<!--统一管理jar包和版本-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
<lombok.version>1.16.18</lombok.version>
<mysql.version>5.1.47</mysql.version>
<druid.verison>1.1.16</druid.verison>
<mybatis.spring.boot.verison>1.3.0</mybatis.spring.boot.verison>
</properties>
<!-- dependencyManagement 父工程同一版本:子模块继承之后,提供作用:锁定版本+子modlue不用写groupId和version -->
<dependencyManagement>
<dependencies>
<!-- springboot 与 springcloud 版本需要搭配 以下是官方推荐的搭配-->
<!-- spring boot 2.2.2-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- spring cloud Hoxton.SR1-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- spring cloud alibaba 2.1.0.RELEASE-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- MySql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- Druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.verison}</version>
</dependency>
<!-- mybatis-springboot整合 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.verison}</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<!--junit-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
3.maven跳过单元测试:右侧 Maven Projects 设置 【长得像闪电的那个图标选中即可】
父工程执行install发布到仓库,方便子类继承
4.建数据库、建表
/*
Source Server : 本地 test
Source Server Version : 50622
Source Host : localhost:3306
Source Database : demo2020
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for payment
-- ----------------------------
DROP TABLE IF EXISTS `payment`;
CREATE TABLE `payment` (
`id` bigint(20) NOT NULL COMMENT '主键',
`serial` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of payment
-- ----------------------------
INSERT INTO `payment` VALUES ('1', '尚硅谷');
INSERT INTO `payment` VALUES ('2', 'alibaba');
INSERT INTO `payment` VALUES ('3', '京东');
INSERT INTO `payment` VALUES ('4', '头条');
5.子模块开始…见代码咯
https://gitee.com/JayinChan/demo2020
上一篇: 【电商项目】---实现登录
下一篇: 链表相关算法