跳至主要內容

apzs...大约 9 分钟

运行Java项目

所需软件

工具版本官方网站下载地址
jdk1.8javaopen in new window点击下载open in new window
maven3.6.1Maven – Welcome to Apache Mavenopen in new window点击下载open in new window
mysql5.7mysqlopen in new window点击查看镜像open in new window
nacos1.1.3nacosopen in new window点击下载open in new window
nginx1.10nginxopen in new window点击查看镜像open in new window
redislatestredisopen in new window点击查看镜像open in new window
seata0.7.1seataopen in new window点击下载open in new window
rabbitmqlatestrabbitmqopen in new window点击查看镜像open in new window
kibana7.4.2kibanaopen in new window点击查看镜像open in new window
elasticsearch7.4.2elasticsearchopen in new window点击查看镜像open in new window
openzipkin/zipkinlatestzipkinopen in new window点击查看镜像open in new window

点击Customize里的All settings...

image-20221128131705752
image-20221128131705752

Build,Execution, DeploymentBuild ToolsMaven,修改为自己Maven的路径

image-20221128131648206
image-20221128131648206

编码全部设为UTF-8,一定要勾选Transparent native-to-ascii conversion将文件转码为UTF-8

image-20221221085502080
image-20221221085502080

然后打开,一直等,等到下载全部完成,大概需要10分钟

image-20221128132317300
image-20221128132317300

下载完成后,如果这个pom.xml文件是橘红色,右键选择Add as Maven Project就行了

image-20221128140727671
image-20221128140727671

首先运行网关模块,运行网关模块之前需要启动nacos

双击\bin\startup.cmd即可

image-20221128162043956
image-20221128162043956

没报错就证明成功了

image-20221128162020403
image-20221128162020403

然后运行网关模块

image-20221128141829648
image-20221128141829648

错误1

这个错误是有些模块的语法用的不是jdk8

D:\gulimall\gulimall-common\src\main\java\com\atguigu\common\utils\Query.java:44:33
java: -source 1.5 中不支持 diamond 运算符
  (请使用 -source 7 或更高版本以启用 diamond 运算符)
image-20221128141054713
image-20221128141054713
image-20221128141220901
image-20221128141220901
image-20221128141241194
image-20221128141241194

吧这些模块都改为8 - Lambdas, type annotations etc.

image-20221128141305540
image-20221128141305540
image-20221128142143762
image-20221128142143762
image-20221128142123687
image-20221128142123687

错误2

这是因为刚刚使用的低版本的jdk编译的,清除一下缓存就行了

java: Compilation failed: internal java compiler error
image-20221128141541050
image-20221128141541050
image-20221128141701108
image-20221128141701108

网关模块运行成功

image-20221128161914374
image-20221128161914374

maven打包,先禁用test

image-20221128162231874
image-20221128162231874

然后点击install

image-20221128162258372
image-20221128162258372

错误3

image-20221128160956167
image-20221128160956167

这些模块的Language level:全部修改为8 - Lambdas, type annotations etc.(我已经修改过了,不知道怎么回事又变回去了)

image-20221128162403142
image-20221128162403142

这些模块的jdk版本我已经修改为1.8了,又给我变成1.5了,再次修改过来

image-20221128161634858
image-20221128161634858
  <proxies>
 	<profile>
        <id>jdk1.8</id>
        <activation>
        	<activeByDefault>true</activeByDefault>
        	<jdk>1.8</jdk>
        </activation>
        <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>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
        </properties>
	</profile>
  </proxies>
image-20221128161207030
image-20221128161207030

至此,项目全部打包完成

image-20221128162631181
image-20221128162631181

运行mysql

下载mysql:5.7镜像

sudo docker pull mysql:5.7

使用如下命令启动mysql

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7

如果报错了,可以使用如下命令(即mysql/etc/mysql目录下的配置文件移动到了/etc/mysql/conf.d)

docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7

运行mysql8容器命令

docker run -d \
-p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=root \
 mysql:8.0.29

设置容器自启动

docker  update --restart=always mysql

添加数据

mydata移动到linux的根目录

image-20221221101405719
image-20221221101405719
image-20221221101537483
image-20221221101537483

如果是第二个命令运行的(即挂载mysql的/etc/mysql/conf.d)

使用docker logs mysql命令,查看日志会报如下错误:

mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
2022-12-21 01:45:28+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.40-1.el7 started.
2022-12-21 01:45:28+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config
        command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.9UoxqfaUar
        mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 2 - No such file or directory)
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
image-20221221102257888
image-20221221102257888

需要将/mydata/mysql里的conf文件夹删掉

image-20221221101907214
image-20221221101907214

然后使用我提供的这个conf

image-20221221102030424
image-20221221102030424

测试连接:

image-20221221102552698
image-20221221102552698

此时数据都显示出来了

image-20221221102622790
image-20221221102622790

运行redis

下载最新的redis

docker pull redis

运行redis

docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
docker  update --restart=always redis

运行nginx

下载并运行nginx

docker run -p 80:80 --name nginx \
-v /mydata/nginx/html:/usr/share/nginx/html \
-v /mydata/nginx/logs:/var/log/nginx \
-v /mydata/nginx/conf:/etc/nginx \
-d nginx:1.10
docker  update --restart=always nginx

运行elasticsearch

docker pull elasticsearch:7.4.2
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.4.2
docker  update --restart=always elasticsearch

使用docker ps -a命令,发现没有启动

image-20221221130302887
image-20221221130302887

使用docker logs elasticsearch命令,查看日志,报了没有权限的异常

"Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes/0/node.lock",
"at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]",
"at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]",
"at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?]",
"at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:182) ~[?:?]",
"at java.nio.channels.FileChannel.open(FileChannel.java:292) ~[?:?]",
"at java.nio.channels.FileChannel.open(FileChannel.java:345) ~[?:?]",
"at org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:125) ~[lucene-core-8.2.0.jar:8.2.0 31d7ec7bbfdcd2c4cc61d9d35e962165410b65fe - ivera - 2019-07-19 15:05:56]",
"at org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:41) ~[lucene-core-8.2.0.jar:8.2.0 31d7ec7bbfdcd2c4cc61d9d35e962165410b65fe - ivera - 2019-07-19 15:05:56]",
"at org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:45) ~[lucene-core-8.2.0.jar:8.2.0 31d7ec7bbfdcd2c4cc61d9d35e962165410b65fe - ivera - 2019-07-19 15:05:56]",
"at org.elasticsearch.env.NodeEnvironment$NodeLock.<init>(NodeEnvironment.java:214) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:269) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.node.Node.<init>(Node.java:275) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.node.Node.<init>(Node.java:255) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:221) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:221) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.4.2.jar:7.4.2]",
"... 6 more"] }
image-20221221130206529
image-20221221130206529

进入/mydata/目录,使用如下命令,修改elasticsearch文件夹的用户权限

chmod -R 777 elasticsearch
image-20221221131202311
image-20221221131202311

过了一会又报了一个新的错误

"Caused by: java.io.IOException: failed to find metadata for existing index newbank [location: jPkFm8qRSNmRogBqujQyyA, generation: 309]",
"at org.elasticsearch.gateway.MetaStateService.loadFullState(MetaStateService.java:99) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.gateway.GatewayMetaState.upgradeMetaData(GatewayMetaState.java:141) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.gateway.GatewayMetaState.<init>(GatewayMetaState.java:95) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.node.Node.<init>(Node.java:485) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.node.Node.<init>(Node.java:255) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:221) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:221) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.4.2.jar:7.4.2]",
"at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.4.2.jar:7.4.2]",
"... 6 more"] }
image-20221221140030067
image-20221221140030067

这是因为是直接将数据复制过来的,删掉data/nodes/0/_state/manifest开头的文件就行了

cd /mydata/elasticsearch/data/nodes/0/_state/
rm -rf manifest-2442.st
docker start elasticsearch
docker ps
image-20221221140524239
image-20221221140524239

运行kibana

docker pull kibana:7.4.2
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.56.10:9200 -p 5601:5601 \
-d kibana:7.4.2
docker  update --restart=always kibana

直接访问 http://192.168.56.10:5601/ 就行了

image-20221221140557478
image-20221221140557478

rabbitmq

docker run -d --name rabbitmq
-p 5671:5671 -p 5672:5672 -p 4369:4369 -p  25672:25672 -p 15671:15671 -p 15672:15672  
rabbitmq:management
docker  update --restart=always rabbitmq
image-20221221141448985
image-20221221141448985

直接访问 http://192.168.56.10:15672/ 即可

image-20221221141506778
image-20221221141506778

zipkin

docker run -d -p 9411:9411 openzipkin/zipkin
docker  update --restart=always frosty_shamir

访问 http://192.168.56.10:9411/ 即可

image-20221221142555321
image-20221221142555321

修改Host文件

C:\Windows\System32\drivers\etc文件夹里的hosts文件里,添加配置,然后保存

192.168.56.10  gulimall.com
192.168.56.10  search.gulimall.com
192.168.56.10  item.gulimall.com
192.168.56.10  auth.gulimall.com
192.168.56.10  cart.gulimall.com
192.168.56.10  order.gulimall.com
192.168.56.10  member.gulimall.com
192.168.56.10  seckill.gulimall.com
image-20221221113653615
image-20221221113653615

启动nacos和seata

双击nacos\bin\startup.cmd

image-20221221154424514
image-20221221154424514

seata需要将conf\registry.conf文件里的type修改为nacosnacos.serverAddr修改为localhost:8848

image-20221221155845058
image-20221221155845058

双击seata-server-0.7.1\bin\seata-server.bat

image-20221221154523474
image-20221221154523474

如果不修改seata配置,gulimall-order模块会报如下错误

2022-12-21 15:48:40.149 ERROR [gulimall-order,,,] 21648 --- [imeoutChecker_1] i.s.c.r.netty.NettyClientChannelManager  : no available server to connect.
image-20221221160234107
image-20221221160234107

运行各个模块

nacos的错不用管

image-20221221152459468
image-20221221152459468

报了rabbitmq的错误

Caused by: org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[hello-java-queue]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:711) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.passiveDeclarations(BlockingQueueConsumer.java:595) ~[spring-rabbit-2.1.8.RELEASE.jar:2.1.8.RELEASE]
	... 4 common frames omitted
image-20221221151337558
image-20221221151337558

这是因为没有名为hello-java-queue的队列,注释掉gulimall-order模块的com.atguigu.gulimall.order.test.ReceiveMessage2类的@RabbitListener(queues = {"hello-java-queue"})即可

image-20221221153952680
image-20221221153952680

运行前端后台管理项目

使用10.16.3版本的node.jsopen in new window

image-20221222133322476
image-20221222133322476

使用node -v验证版本

image-20221222133454803
image-20221222133454803

然后在cmd中执行如下命令

## 添加淘宝镜像
npm config set registry http://registry.npm.taobao.org/
## 设置全局包下载路径(相当于maven的仓库)
npm config set cache "D:/nodejs/npm_global"
## 设置缓存文件位置
npm config set prefix "D:/nodejs/npm_cache"
image-20221222134851281
image-20221222134851281

使用npm install命令下载依赖,报了如下错误

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7CCE7DD8A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506
 2: 00007FF7CCE58886 node::MakeCallback+4534
 3: 00007FF7CCE59200 node_module_register+2032
 4: 00007FF7CD1730DE v8::internal::FatalProcessOutOfMemory+846
 5: 00007FF7CD17300F v8::internal::FatalProcessOutOfMemory+639
 6: 00007FF7CD359804 v8::internal::Heap::MaxHeapGrowingFactor+9620
 7: 00007FF7CD3507E6 v8::internal::ScavengeJob::operator=+24550
 8: 00007FF7CD34EE3C v8::internal::ScavengeJob::operator=+17980
 9: 00007FF7CD354D87 v8::internal::Heap::CreateFillerObjectAt+1175
10: 00007FF7CD6F27D3 v8::internal::NativesCollection<0>::GetScriptsSource+547
11: 00007FF7CCDDFD92 v8::internal::StackGuard::ArchiveSpacePerThread+52242
12: 00007FF7CCDE0453 v8::internal::StackGuard::ArchiveSpacePerThread+53971
13: 00007FF7CCEC1614 uv_dlerror+2452
14: 00007FF7CCEC23E8 uv_run+232
15: 00007FF7CCE5FE7E node::NewContext+1390
16: 00007FF7CCE6048B node::NewIsolate+603
17: 00007FF7CCE608E7 node::Start+823
18: 00007FF7CCD0F3CC node::MultiIsolatePlatform::MultiIsolatePlatform+604
19: 00007FF7CD95863C v8::internal::compiler::OperationTyper::ToBoolean+129516
20: 00007FFC5178244D BaseThreadInitThunk+29
21: 00007FFC52C4DFB8 RtlUserThreadStart+40
image-20221222134851282
image-20221222134851282

删掉用户目录下的.npmrc文件(C:\Users\pc01\.npmrc)

image-20221222135139919
image-20221222135139919

再次使用npm install命令下载依赖,显示node-sass安装失败

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})      

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\pc01\AppData\Roaming\npm-cache\_logs\2022-12-22T05_52_48_531Z-debug.log
image-20221222135318140
image-20221222135318140

重新安装node-sass

## 卸载掉安装失败的node-sass
npm uninstall node-sass
## 重新安装sass
npm install sass -i
image-20221222135717972
image-20221222135717972

再次使用npm install命令安装,提示有656个漏洞不用管

PS D:\renren-fast-vue> npm install
npm WARN [email protected] requires a peer of ajv@>=4.10.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\sass\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})      
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})      

audited 2311 packages in 6.589s
found 656 vulnerabilities (56 low, 179 moderate, 318 high, 103 critical)
  run `npm audit fix` to fix them, or `npm audit` for details
image-20221222135838426
image-20221222135838426

使用npm run dev运行项目提示没有发现node-sass模块

Module build failed: Error: Cannot find module 'node-sass'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
image-20221222140046492
image-20221222140046492

卸载掉以前的node-sass,重新安装node-sass,还是报错

npm uninstall --save node-sass
npm install --save node-sass
image-20221222140600261
image-20221222140600261

换成4.14.1版本就好了

npm install --save [email protected]
image-20221222141650512
image-20221222141650512

再次使用npm run dev就运行成功了

image-20221222141857800
image-20221222141857800

访问 http://localhost:8001/ 即可(如果没有验证码,需要后台启动gulimall-gatewayrenren-fast模块)

image-20221222155305626
image-20221222155305626
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.0.0-alpha.8