记JFinal项目上传到宝塔并运行

记JFinal项目部署到宝塔并运行

配置项目

这里使用了默认的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 进行转换

运行
打开浏览器
输入地址
部署成功!

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值