作者:正在减肥的小小_519 | 来源:互联网 | 2024-10-08 11:26
1.对于maven构建spring-boot web工程。pom.xml
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0modelVersion>
<parent>
<groupId>cn.gitv.bigroupId>
<artifactId>hadoopartifactId>
<version>1.0-SNAPSHOTversion>
parent>
<artifactId>hadoop-internal-apiartifactId>
<name>hadoop-internal-apiname>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<maven.compiler.target>1.7maven.compiler.target>
<maven.compiler.source>1.7maven.compiler.source>
properties>
<build>
<finalName>hadoop-internal-api-${project.version}finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-assembly-pluginartifactId>
<version>2.3version>
<configuration>
<appendAssemblyId>trueappendAssemblyId>
<descriptors>
<descriptor>assembly.xmldescriptor>
descriptors>
configuration>
<executions>
<execution>
<id>make-assemblyid>
<phase>packagephase>
<goals>
<goal>singlegoal>
goals>
execution>
executions>
plugin>
plugins>
build>
<dependencies>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
<scope>testscope>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-webartifactId>
dependency>
<dependency>
<groupId>cn.gitv.bigroupId>
<artifactId>hadoop-hbase-daoartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
<dependency>
<groupId>cn.gitv.bigroupId>
<artifactId>hadoop-commonartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
dependencies>
project>
- assembly.xml
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>binid>
<formats>
<format>tar.gzformat>
formats>
<fileSets>
<fileSet>
<directory>${project.basedir}directory>
<outputDirectory>/outputDirectory>
<includes>
<include>README*include>
<include>LICENSE*include>
<include>NOTICE*include>
includes>
fileSet>
<fileSet>
<directory>src/main/resources/scriptsdirectory>
<outputDirectory>binoutputDirectory>
fileSet>
fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/outputDirectory>
<useProjectArtifact>trueuseProjectArtifact>
dependencySet>
dependencySets>
assembly>
- 运行脚本 run.sh
#!/bin/bash
SCRIPT_HOME=$(dirname $(readlink -f $0))
bash -ex $SCRIPT_HOME/startup.sh 9000
4.startup.sh
#!/bin/bash
JAVA_OPTS="-server -Xms1024m -Xmx1024m -Xmn384m -XX:MaxPermSize=64m \
-Xss256k -XX:+UseConcMarkSweepGC \
-XX:+UseParNewGC -XX:CMSFullGCsBeforeCompaction=5 \
-XX:+UseCMSCompactAtFullCollection \
-XX:+PrintGC -Xloggc:/data/bi/hadoop-internal-api/logs/gc.log"
PHOME=$(dirname `readlink -f "$0"`)
PHOME=$(dirname $PHOME)
pid=`ps -eo pid,args | grep hadoop-internal-api | grep 9000 | grep java | grep -v grep | awk '{print $1}'`
if [ -n "$pid" ]
then
kill -3 ${pid}
kill ${pid} && sleep 3
if [ -n "`ps -eo pid | grep $pid`" ]
then
kill -9 ${pid}
fi
echo "kill pid: ${pid}"
fi
java $JAVA_OPTS -cp $PHOME/conf:$PHOME/lib/* cn.gitv.bi.internal.api.Application $1 > /dev/null 2>&1 &
注意:如果是从windows写的脚本放到linux上
由于windows下对文本文件的保存格式与unix下不同造成的,windows下回车的字符是’\r\n’,而linux下是’\n’。
head -1 run.sh |od -c
可以看到
需要运行命令转换格式
dos2unix run.sh
dos2unix startup.sh