1. IDEA项目搭建
1.1 IDEA下载与安装
IDEA Ultimate版本安装教程转载https://javamana.com/2021/05/20210510064135472q.html
1.2 Maven 下载与配置
Maven 下载安装配置教程转载maven的下载安装配置教程(详细图文) - 砰砰的猿 - 博客园 (cnblogs.com)
1.3 项目工程搭建
-
点击new project,选择Maven项目 -
设置项目选择项目的根目录,设置项目名称,修改包名,之后点击Finish -
左上角FIle -> Setting -> Build, Excution, Deployment -> Build Tools ->Maven,修改Maven home path为你安装的Maven的根目录,并修改User setting file为Maven根目录下settings.xml的路径,Local repository修改为Maven配置的本地仓库的路径,最后将这两个勾选为Override。 -
在POM.xml文件下导入下列依赖 <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
</parent>
<properties>
<mysql.version>5.1.47</mysql.version>
<jackson.version>2.9.9</jackson.version>
<druid.version>1.0.9</druid.version>
<servlet-api.version>2.5</servlet-api.version>
<jsp-api.version>2.0</jsp-api.version>
<joda-time.version>2.5</joda-time.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<commons-io.version>1.3.2</commons-io.version>
<mybatis.version>3.2.8</mybatis.version>
<mybatis.mybatis-plus>3.1.1</mybatis.mybatis-plus>
<lombok.version>1.18.4</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>${mybatis.mybatis-plus}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>3.9.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
点击右上角的按键,刷新Maven
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gsmFjv0R-1649164525886)(D:\WORK\FF\images\39.jpg)]
左侧项目目录下,External Libraries一栏打开,若如下图基本相同,则说明导入成功
2. redis 和 RocketMQ 搭建
2.1 配置Ubuntu虚拟机
2.2 搭建redis集群
- ctrl + alt + T 打开终端
- 安装docker,输入
sudo apt install docker.io ,然后输入你的用户密码,有选择就输入y 。
sudo gpasswd -a $USER docker
newgrp docker
docker ps
- 部署Redis集群,该集群有3个节点,每行命令后出现框出的部分,则说明创建成功。
docker create --name redis-node01 --net host -v redis-node01:/data
redis:5.0.2 --cluster-enabled yes --cluster-config-file nodes-node-01.conf
--port 6379
docker create --name redis-node02 --net host -v redis-node02:/data
redis:5.0.2 --cluster-enabled yes --cluster-config-file nodes-node-02.conf
--port 6380
docker create --name redis-node03 --net host -v redis-node03:/data
redis:5.0.2 --cluster-enabled yes --cluster-config-file nodes-node-03.conf
--port 6381
2.3 RocketMQ搭建
-
点击快捷键 Ctrl + D 退出docker容器。 -
输入sudo -s 授予当前用户root权限。 -
输入sudo apt-get install vim 安装vim,遇到[Y/n]输入y ,接着一路enter。 -
拉取镜像 docker pull foxiswho/rocketmq:server-4.3.2
docker pull foxiswho/rocketmq:broker-4.3.2
?
-
创建nameserver容器 docker create -p 9876:9876 --name rmqserver \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-e "JAVA_OPTS=-Duser.home=/opt" \
-v rmqserver-logs:/opt/logs \
-v rmqserver-store:/opt/store \
foxiswho/rocketmq:server-4.3.2
-
创建broker.conf文件 vim /itcast/rmq/rmqbroker/conf/broker.conf
brokerIP1=你的ip地址
namesrvAddr=你的ip地址:9876
brokerName=broker_tanhua
按ESC进入Command模式,输入:wq 保存文件并退出vi编辑器。 -
创建broker容器 docker create -p 10911:10911 -p 10909:10909 --name rmqbroker \
-e "JAVA_OPTS=-Duser.home=/opt" \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
-v /itcast/rmq/rmqbroker/conf/broker.conf:/etc/rocketmq/broker.conf \
-v rmqbroker-logs:/opt/logs \
-v rmqbroker-store:/opt/store \
foxiswho/rocketmq:broker-4.3.2
docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=你的ip地址:9876 -
Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t
- 命令行不再跳动的时候,在浏览器中访问 你的ip:8082 ,出现以下界面,说明搭建成功。
|