maven 플러그 인 assembly 사용 및 springboot 시작 스 크 립 트 start.sh 와 스 크 립 트 정지 stop.sh
1.우선 포장 전의 프로젝트 파일 구 조 를 살 펴 봅 니 다.
2.pom.xml 에 assembly 플러그 인 설정
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- package -->
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
3.assembly 이 디 렉 터 리 에 assembly.xml 파일 을 추가 합 니 다.
<assembly>
<id>assembly</id>
<formats>
<!-- -->
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/assembly/bin</directory>
<outputDirectory>/bin</outputDirectory>
<includes>
<include>*.sh</include>
</includes>
<!-- -->
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<!-- -->
<directory>src/main/resources</directory>
<!-- -->
<outputDirectory>/conf</outputDirectory>
</fileSet>
<!-- jar -->
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
<!-- jar -->
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
4.assembly:assembly 를 클릭 하면 포장 이 가능 합 니 다.5.가방 을 정리 한 파일 보기
5、start.sh,stop.sh 파일 첨부
start.sh 파일
#!/usr/bin/env bash
#source $(dirname $0)/../../env.sh
SERVERJAR="database-project-0.0.1-SNAPSHOT.jar"
base_dir=$(dirname $0)
cd ..
if [ "$JAVA_HOME" != "" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=java
fi
JAVA_OPTS="-server -Xms32m -Xmx32m -Xmn24m -Xss256K \
-XX:SurvivorRatio=4 -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection \
-XX:CMSInitiatingOccupancyFraction=60 -XX:+PrintGCDateStamps \
-XX:+PrintGCDetails -Xloggc:$base_dir/gc.log"
echo -n "Starting server ..."
PID=$(ps -ef | grep database-project-0.0.1-SNAPSHOT.jar | grep -v grep |awk '{print $2}')
if [ -z "$PID" ]; then
echo Application is already stopped
else
echo kill $PID
kill -9 $PID
fi
echo `pwd`
echo $SERVERJAR
echo $JAVA
echo $JAVA_OPTS
echo $JAVA_DEBUG_OPT
nohup $JAVA $JAVA_OPTS $JAVA_DEBUG_OPT -jar lib/$SERVERJAR > $base_dir/nohup.out &
if [ $? -eq 0 ];then
# echo -n $! > "$PIDFILE"
if [ $? -eq 0 ]
then
sleep 1
echo STARTED
else
echo FAILED TO WRITE PID
exit 1
fi
else
echo SERVER DID NOT START
exit 1
fi
stop.sh
#!/usr/bin/env bash
SERVERJAR="database-project-0.0.1-SNAPSHOT.jar"
base_dir=$(dirname $0)
echo -n "Stopping server ..."
PID=$(ps -ef | grep database-project-0.0.1-SNAPSHOT.jar | grep -v grep |awk '{print $2}')
if [ -z "$PID" ]; then
echo Application is already stopped
else
echo kill $PID
kill -9 $PID
fi
exit 0
파일 압축 풀기 start.sh 파일 실행스 크 립 트 의 뜻 은 참고 할 수 있다
https://www.jb51.net/article/39506.htm
로 그 는 참고 할 수 있 습 니 다.
https://www.jb51.net/article/152599.htm
시작 실행 매개 변 수 를 참고 할 수 있 습 니 다.
https://www.jb51.net/article/161958.htm
https://www.jb51.net/article/107058.htm
스 크 립 트 를 시작 할 때.../start.sh 스 크 립 트 를 시작 할 때 오류 가 발생 할 수 있 습 니 다.
No such file or directory
이것 은 윈도 우즈 에서 작 성 된 스 크 립 트 파일 로 리 눅 스에 서 형식 을 식별 할 수 없 기 때문에 start.sh 와 stop.sh 스 크 립 트 파일 을 편집 하고 set ff=unix 를 linux 환경 으로 설정 합 니 다
set ff=unix
스 크 립 트 시작 상황 보기
tail -f -n 500 nohup.out
총결산
Maven 플러그 인 assembly 사용 및 springboot 시작 스 크 립 트 start.sh 와 스 크 립 트 정지 stop.sh 에 관 한 이 글 은 여기까지 소개 합 니 다.더 많은 관련 Maven 플러그 인 assembly 는 springboot 를 사용 하여 스 크 립 트 정지 내용 을 시작 합 니 다.이전 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 많은 지원 바 랍 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Windows에서 CodeArtifact(Maven)용 토큰을 자동으로 생성하는 방법CodeArtifact를 사용한 적이 있거나 사용할 계획이라면 매일 모든 Maven 프로젝트에서 수동으로 토큰(CODEARTIFACT_AUTH_TOKEN)을 생성해야 합니다. 이는 어려울 수 있으며 개발 속도를 늦출...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.