打包命令
前台js打包 需要:node.js
普通WEB项目 需要:ant
ant -buildfile build.xml #进入项目目录,在有build.xml的目录,使用命令打包
|
maven项目 需要:maven
maven clean install -P{profile} -Dmaven.test.skip=true #clean清理本地库 install编译打包可执行的war -P指定多环境参数 -Dmaven.test.skip=true 跳过测试
|
启动命令
spring项目
java -jar nmk.jar --spring.profiles.active=dev #可在java后配置启动参数 -Xms512m -Xmx1024m 限制项目使用内存 #--spring.profiles.active 指定多环境 #在linux启动请在启动命令最后加& 代表后台运行,如果项目在你断掉连接时挂掉请使用nohup+& #示例如下: #nohup java -Xms512m -Xmx1024m -jar nmk.jar --spring.profiles.active=prod >> catalina.out 2>&1 & #指定程序后台启动,使用prod环境配置运行,最大堆内存为1024M,启动日志输出到catalina.out
|
tomcat项目
windows下
把war包或文件夹放入tomcat/webapps下,启动tomcat/bin目录下的startup.bat 可在catalina.bat开头配置堆内存 set JAVA_OPTS=-server -Xms512m -Xmx1024m
|
linux下
把war包或文件夹放入tomcat/webapps下,进入tomcat/bin目录下 chmod +x startup.sh #授权执行权限 chmod +x catalina.sh ./startup.sh 或sh startup.sh启动tomcat 可在catalina.sh开头配置堆内存 JAVA_OPTS="-Xms512m -Xmx1024m"
|
*项目环境必须有安装JDK
bug:
项目中图片中文名称,访问页面不显示问题
修改tomcat的conf/server.xml,增加编码格式
修改前<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="18883" URIEncoding="UTF-8"/> 修改后<Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8" connectionTimeout="20000" redirectPort="443"/>
|
重启tomcat即可解决
maven将jar包添加到本地仓库
情景描述:当项目所需的jar包,maven中央仓库中没有该jar包时,如何将jar包添加到本地仓库呢?
错误做法:直接将jar包拷贝到本地仓库目录下
正确做法: 1.首先,搭建maven运行环境; 2. 使用maven命令,将jar包添加到本地仓库;
maven安装jar包的命令是:
mvn install:install-file -Dfile=jar包的位置 -DgroupId=设置groupId -DartifactId=设置artifactId -Dversion=设置version -Dpackaging=jar
|
前端打包失败
在windows打包成功,在jenkins中打包失败,查看npm和node发现版本不一致
查看其版本
node -v v15.1.0
npm -v 7.0.8
|
更新
更新npm : npm install -g npm 更新指定版本 : npm install -g npm@6.9.0 更新node版本: 首先安装n模块 npm install -g n 安装好n模块后可以选择下面其一升级:
选择一:升级node.js到最新稳定版 n stable
选择二:升级node.js到最新版 n latest
选择三:升级node.js到指定版本 n v14.16.0 如果出现没有n命令提示,请进入node安装目录的bin下进行执行
|
还是出现报错
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/hotword/components/recommend.vue Module not found: Error: Can't resolve './RecommendCreate' in '/home/jenkins/workspace/liang_jian_web_dev/src/project/views/hotword/components' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/hotword/components/recommend.vue 15:23-51 @ ./src/project/views/hotword/components/recommend.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/hotword/list.vue @ ./src/project/views/hotword/list.vue @ ./src/project/router/hotword.js @ ./src/project/router/index.js @ ./src/main.js
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/hotword/components/recommend.vue Module not found: Error: Can't resolve './RecommendEdit' in '/home/jenkins/workspace/liang_jian_web_dev/src/project/views/hotword/components' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/hotword/components/recommend.vue 19:21-47 @ ./src/project/views/hotword/components/recommend.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/hotword/list.vue @ ./src/project/views/hotword/list.vue @ ./src/project/router/hotword.js @ ./src/project/router/index.js @ ./src/main.js
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/video/list.vue Module not found: Error: Can't resolve './SetAmount' in '/home/jenkins/workspace/liang_jian_web_dev/src/project/views/video' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/video/list.vue 31:17-39 @ ./src/project/views/video/list.vue @ ./src/project/router/video.js @ ./src/project/router/index.js @ ./src/main.js
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/editWord.vue Module not found: Error: Can't resolve '@/project/service/watermark' in '/home/jenkins/workspace/liang_jian_web_dev/src/project/views/waterMark' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/editWord.vue 11:17-55 @ ./src/project/views/waterMark/editWord.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/list.vue @ ./src/project/views/waterMark/list.vue @ ./src/project/router/waterMark.js @ ./src/project/router/index.js @ ./src/main.js
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/editImage.vue Module not found: Error: Can't resolve '@/project/service/watermark' in '/home/jenkins/workspace/liang_jian_web_dev/src/project/views/waterMark' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/editImage.vue 15:17-55 @ ./src/project/views/waterMark/editImage.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/list.vue @ ./src/project/views/waterMark/list.vue @ ./src/project/router/waterMark.js @ ./src/project/router/index.js @ ./src/main.js
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/createWord.vue Module not found: Error: Can't resolve '@/project/service/watermark' in '/home/jenkins/workspace/liang_jian_web_dev/src/project/views/waterMark' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/createWord.vue 11:17-55 @ ./src/project/views/waterMark/createWord.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/list.vue @ ./src/project/views/waterMark/list.vue @ ./src/project/router/waterMark.js @ ./src/project/router/index.js @ ./src/main.js
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/createImage.vue Module not found: Error: Can't resolve '@/project/service/watermark' in '/home/jenkins/workspace/liang_jian_web_dev/src/project/views/waterMark' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/createImage.vue 15:17-55 @ ./src/project/views/waterMark/createImage.vue @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/project/views/waterMark/list.vue @ ./src/project/views/waterMark/list.vue @ ./src/project/router/waterMark.js @ ./src/project/router/index.js @ ./src/main.js
Build failed with errors.
npm ERR! code 1 npm ERR! path /home/jenkins/workspace/liang_jian_web_dev npm ERR! command failed npm ERR! command sh -c node build/build.js
npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-03-08T06_33_52_235Z-debug.log
|
百度找到问题原因
注意大小写, windows对大小写不敏感,大小写都是对的, linux对大小写很敏感,不对就会报错
|
修改项目中的大小写,再次编译打包成功