如何使用rpm maven插件在linux上运行我的应用程序?
我想使用rpm maven插件将我的maven项目打包到rpm文件中。maven安装(如何使用rpm maven插件在linux上运行我的应用程序?,maven,rpm,rpmbuild,rpm-spec,rpm-maven-plugin,Maven,Rpm,Rpmbuild,Rpm Spec,Rpm Maven Plugin,我想使用rpm maven插件将我的maven项目打包到rpm文件中。maven安装(mvn clean install)后,rpm将在target/rpm/rpm build/RPMS/noarch/中创建。 如何启动应用程序? 如果我尝试使用yum localinstall{name}.rpm安装rpm,我会得到一个提示:没有什么事情要做: : 我在安装后创建了一个文本文件来理解这个例程 在我看来,生成的spec文件看起来很奇怪,因为tmp buildroot/是空的: %define __
mvn clean install
)后,rpm将在target/rpm/rpm build/RPMS/noarch/
中创建。
如何启动应用程序?
如果我尝试使用yum localinstall{name}.rpm安装rpm,我会得到一个提示:没有什么事情要做:
:
我在安装后创建了一个文本文件来理解这个例程
在我看来,生成的spec文件看起来很奇怪,因为tmp buildroot/是空的:
%define __jar_repack 0
Name: rpm-build
Version: 0.5.0
Release: SNAPSHOT20160809082044
Summary: rpm-build
License: (c) 2016 Nobody
Vendor: Nobody
URL: http://www.Nobody.com
Group: Development
Packager: Nobody
autoprov: yes
autoreq: yes
BuildArch: noarch
BuildRoot: /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/buildroot
%description
test example: RPM Package.
%install
if [ -d $RPM_BUILD_ROOT ];
then
mv /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/tmp-buildroot/* $RPM_BUILD_ROOT
else
mv /mnt/hgfs/workspace/test/rpm-build/target/rpm/rpm-build/tmp-buildroot $RPM_BUILD_ROOT
fi
%files
"/opt/app//lib/"
%config "/opt/app//conf"
%dir "/opt/app//logs"
%pre
echo "installing now"
%post
#!/usr/bin/env bash
touch file.txt
我的pom中缺少哪个参数
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>nobody</artifactId>
<groupId>com.nobody.nobody</groupId>
<version>0.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rpm-build</artifactId>
<inceptionYear>2016</inceptionYear>
<organization>
<name>nobody</name>
<url>http://www.nobody.com</url>
</organization>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<app.home>/opt/app/</app.home>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1.5</version>
<executions>
<execution>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
<configuration>
<group>Development</group>
<description>example: RPM Package.</description>
<mappings>
<mapping>
<directory>${app.home}/lib/</directory>
<dependency/>
<artifact/>
</mapping>
<mapping>
<directory>${app.home}/conf</directory>
<configuration>true</configuration>
<sources>
<source>
<location>${project.build.outputDirectory}/app.properties</location>
<destination>app.sample.properties</destination>
</source>
</sources>
</mapping>
<mapping>
<directory>${app.home}/logs</directory>
</mapping>
</mappings>
<preinstallScriptlet>
<script>echo "installing now"</script>
</preinstallScriptlet>
<postinstallScriptlet>
<scriptFile>src/main/scripts/postinstall.sh</scriptFile>
<fileEncoding>utf-8</fileEncoding>
</postinstallScriptlet>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptor>src/assembly/dep.xml</descriptor>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
当前只发送一条System.out.println
消息给我的应用程序。
我的目标是创建一个linux守护进程,我希望通过postinstall脚本可以实现
我希望有人能给我一个提示。谢谢。为什么使用yum localinstall而不是rpm-ivh?