Spring-Boot1.4.0项目部署问题小记

[size=medium]使用最新版的Spring-Boot1.4.0开发完项目后,部署到Linux机器上,其JDK版本是JDK7,启动报错:[/size]
org/eclipse/jetty/webapp/WebAppContext : Unsupported major.minor version 52.0

[size=medium]由于在spring-boot的pom文件里面使用了jetty依赖:[/size]
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<scope>provided</scope>
</dependency>


[size=medium]默认最新的会使用jetty的版本是9.3.11.v20160721,而jetty自从9.3.0开始必须要求使用 JDK8才行,所以项目启动不成功,当然在我自己的windows开发机上是可以启动的,因为我本地的JDK也是8的版本,尝试在spring-boot中降低其依赖jetty的版本,但是没成功,貌似其父parent,在IDEA的maven依赖中,看到jetty版本已经降了,但是打包后,依旧是最新的jetty,比较郁闷,所以就放弃了内嵌的jetty容器,以后有空再研究下原因,暂时采用了spring boot默认web内嵌的tomcat:[/size]
<!-- 默认会引入tomcat作为内嵌容器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

[size=medium]最新的tomcat,兼容JDK7,更改完毕后,启动项目又报错了,由于引入的config版本有点高, 所以就降到1.2.1了,介绍下config,非常不错的一个开源的解析properties,json文件的小神器工具包[/size]
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.2.1</version>
<!-- <version>1.3.0</version> 需要JDK8支持 -->
</dependency>

[size=medium]最后再记录下,使用maven-assemble插件打包没生效的问题,注意

(1)src/main/bin写相对路径即可,打包时会自动拷贝上项目根目录

(2)斜杠不要写反,src\main\bin 在linux上是不会生效的[/size]

<?xml version="1.0"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

<!--项目标识,设置的话,生成后的zip文件会加上此后缀-->
<id></id>
<!--打包格式-->
<formats>
<format>tar.gz</format>
</formats>
<!--是否包含根目录文件夹-->
<includeBaseDirectory>true</includeBaseDirectory>

<fileSets>

<!--自定义文件描述集-->
<fileSet>
<!--自定义脚本目录打包-->
<directory>src/main/bin</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*.*</include>
</includes>
<!--设置权限-->
<fileMode>0755</fileMode>
</fileSet>

<fileSet>
<!--外部配置文件打包-->
<directory>src/main/config</directory>
<outputDirectory>config</outputDirectory>
<includes>
<include>*.*</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>


</fileSets>

<dependencySets>

<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<outputDirectory>lib</outputDirectory>
<!-- 将scope为runtime的依赖包打包到lib目录下。 -->
<scope>runtime</scope>
</dependencySet>
</dependencySets>


</assembly>


[size=medium]最后,备忘下启动任务的脚本:[/size]

root=`pwd`
echo $root

#exit
cs=`echo $root/lib/*jar | sed 's/ /:/g'`
#配置文件的目录,结尾必须加冒号,否则不识别
conf=":$root/config:"
#追加进入cp中
cs=$cs$conf
#打印
echo $cs
#执行
nohup java -cp $cs com.search.bigdata.ApplicationMain &>/dev/null & echo $! >pid&


[b][color=green][size=large]
有什么问题可以扫码关注微信公众号:我是攻城师(woshigcs),在后台留言咨询。
技术债不能欠,健康债更不能欠, 求道之路,与君同行。
[/size][/color][/b]
[img]http://dl2.iteye.com/upload/attachment/0104/9948/3214000f-5633-3c17-a3d7-83ebda9aebff.jpg[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值