Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Service 带嵌入式init.d脚本的Spring启动应用程序在重新启动时未启动_Service_Spring Boot_Centos6_Init.d - Fatal编程技术网

Service 带嵌入式init.d脚本的Spring启动应用程序在重新启动时未启动

Service 带嵌入式init.d脚本的Spring启动应用程序在重新启动时未启动,service,spring-boot,centos6,init.d,Service,Spring Boot,Centos6,Init.d,Spring Boot有一个方便的功能,如果您配置maven插件,它会将init.d starup脚本嵌入到可执行jar中: 因此,我使用上述方法在Centos 6.6中将Spring Boot应用程序(可执行fat jar)作为服务进行“安装” 到目前为止还不错。我创建指向我的jar的链接并设置权限: sudo ln -s /path/to/myapp.jar /etc/init.d/my-service sudo chmod 0755 /etc/init.d/my-service 我

Spring Boot有一个方便的功能,如果您配置maven插件,它会将init.d starup脚本嵌入到可执行jar中:

因此,我使用上述方法在Centos 6.6中将Spring Boot应用程序(可执行fat jar)作为服务进行“安装”

到目前为止还不错。我创建指向我的jar的链接并设置权限:

sudo ln -s  /path/to/myapp.jar  /etc/init.d/my-service
sudo chmod 0755 /etc/init.d/my-service
我可以成功启动应用程序:

sudo service my-service start
但是,我希望应用程序在启动时启动,因此我使用chkconfig实用程序:

sudo chkconfig --add my-service
sudo chkconfig my-service on
这些命令没有错误,但当我重新启动Centos时,服务不会自动启动。 运行:

sudo service my-service status
显示:

Not running
my-service      0:off   1:off   2:on    3:on    4:on    5:on    6:off
运行:

chkconfig --list my-service
显示:

Not running
my-service      0:off   1:off   2:on    3:on    4:on    5:on    6:off
一切看起来都很好,但还没有开始。在这一点上,我可以用“sudo service my service start”手动启动服务,然后它会重新启动,但它不会在启动时自动启动

有什么想法吗?
谢谢,问题解决了。结果是路径问题和我的错。应用程序所在的路径是在启动时不可用的已装入目录

我也有类似的问题,我在运行
服务myapp start时收到以下错误消息

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/JarLauncher : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.springframework.boot.loader.JarLauncher. Program will exit.
但是,我可以通过直接运行
/etc/init.d/app start
使其工作

最后我发现问题是默认的jdk是1.6,尽管当前用户的java是1.8。然后,我改变了符号,它起了作用