觉得之前的那个jekyll的主题太丑了,今天翻新了一下,并把文章和live2d模型迁到了hexo(indigo主题,这次再也不改了)
帮信管专业的同学把项目部署到服务器上,因为没打包过war,中间有个地方卡住了,好麻烦记一下, (推荐了maven

jdbc和tomcat和手写的DAO,怀旧。

用idea打包:

先是在idea里面配置的Webapplication的archive,里面要选一个WEB-INF和META-INF。

将avaliavle elements进行put into outputroot操作,左边的out layout栏里,出现META-INF
build project 再 build artifacts

好了
但是报错了,不知道为啥,war包导出来了,tomcat运行出错。。nmd

项目结构这样

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
├── bin
│   └── out.jar
├── build
│   └── source.txt
├── build.sh
├── classdesign.war
├── out
│   ├── artifacts
│   └── production
├── src
│   ├── com
│   └── MANIFEST.MF
└── web
├── commom
├── css
├── iconfont
├── images
├── js
└── WEB-INF

然后手动打包了,(写了个循环shellfor javac)

代码在这

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/bash
#写到source,做个list,或者直接用idea生成source.txt也可以
path=$(pwd)
dependence(){
for file in `ls $1|grep -v ".bak"`
do
if [ -d $1"/"$file ]
then
dependence $1"/"$file
else
local file_path=$1"/"$file
if echo $file_path|grep "MANIFEST.MF">/dev/null;then
c=c
else
echo $file_path >> $path/build/source
fi
fi
done
}

dependence $path/src
libs=""
for java_lib in $(ls $path/web/WEB-INF/lib);do
if [[ libs != "" ]];then
libs=$libs:$path/web/WEB-INF/lib/$java_lib
else
libs=$path/web/WEB-INF/lib/$java_lib
fi
done

javac -encoding utf-8 -Xlint:unchecked -d $path/build -classpath $path/web/WEB-INF/lib @$path/build/source
jar cvf $path/src/MANIFEST.MF $path/bin/classdesign.war ./*

把war烤到webapps执行startup.sh就可以运行了

2019.7.19更新

在开发板上(无IDE生成MAINFEST)打包注意jar时添加-m追加MAINFEST.MF的Main-Class字段

1
2
3
4
5
6
jar -cvfm test.jar MAINFEST.MF test.class 

MAINFEST.MF

Manifest-Version: 1.0
Main-Class: <MAINCLASSNAME>