配置项目
这里使用了默认的jfinal-undertow
,
pom.xml里的<packaging></packaging>
里面输入jar,
然后在undertow.properties
里面找到undertow.host
将其修改为0.0.0.0(原因是因为后面上传到服务器之后外网才能访问)
然后配置jfinal.sh
找到MAIN_CLASS
修改自己的入口位置 比如我的:
MAIN_CLASS=cn.txy.config.MainConfig
打开 package.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<!--
assembly 打包配置更多配置可参考官司方文档:
http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html
-->
<id>release</id>
<!--
设置打包格式,可同时设置多种格式,常用格式有:dir、zip、tar、tar.gz
dir 格式便于在本地测试打包结果
zip 格式便于 windows 系统下解压运行
tar、tar.gz 格式便于 linux 系统下解压运行
-->
<formats>
<format>zip</format>
<format>tar.gz</format>
</formats>
<!-- 打 zip 设置为 true 时,会在 zip 包中生成一个根目录,打 dir 时设置为 false 少层目录 -->
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<!-- src/main/resources 全部 copy 到 config 目录下 -->
<fileSet>
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>config</outputDirectory>
</fileSet>
<!-- src/main/webapp 全部 copy 到 webapp 目录下 -->
<fileSet>
<directory>${basedir}/src/main/webapp</directory>
<outputDirectory>webapp</outputDirectory>
<excludes>
<exclude>WEB-INF</exclude>
<exclude>WEB-INF/web.xml</exclude>
</excludes>
</fileSet>
<!-- 项目根下面的脚本文件 copy 到根目录下 -->
<fileSet>
<directory>${basedir}</directory>
<outputDirectory></outputDirectory>
<!-- 脚本文件在 linux 下的权限设为 755,无需 chmod 可直接运行 -->
<fileMode>755</fileMode>
<includes>
<include>*.sh</include>
<include>*.bat</include>
</includes>
</fileSet>
</fileSets>
<!-- 依赖的 jar 包 copy 到 lib 目录下 -->
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
若是用的jbolt生成的jfinal项目只需要查看一下是否生成sh文件即可
然后开始打包
mvn clean package
打包完成之后打开目录找到 根目录下target
文件夹
文件夹内生成了一个你的项目名-release
压缩包 记录下来
上传项目
打开宝塔服务器后台
选择文件
我把压缩包上传到 www
目录下解压
打开终端
执行 sh jfinal.sh start
这个时候可能会出现 line: "$'\r': command not found"
这个错误
不慌他表示 执行.sh脚本时出现$’\r’: 未找到命令
这是因为从windows copy到linux目录下的换行符
的原因
windows换行需要 \r\n
linux换行只需要 \n
所以他识别出了问题
这个时候只需要在终端安装转码就行
yum install dos2unix
dos2unix jfinal.sh 进行转换
运行
打开浏览器
输入地址
部署成功!