Why is my spring boot service not starting

Solution 1:

If you intend to fork your application, you need to use Type=forking, or your .service will terminate as soon as the application is placed in the background.

Type=
If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main service process, and the service manager will consider the unit started when the parent process exits. This is the behavior of traditional UNIX services. If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can reliably identify the main process of the service. systemd will proceed with starting follow-up units as soon as the parent process exits.

[Unit]
Description=Spring boot service wfwweb
After=network.target

[Service]
SuccessExitStatus=143
Type=forking
ExecStartPre=java -version
ExecStart=/bin/bash -c \
    'exec -a wfwweb java -jar -Dspring.profiles.active=dev /opt/server/wfwweb-0.9.1.jar &'
# User=user
#Group=group
StandardOutput=append:/var/log/wfwweb/wfwweb.log
 StandardError=append:/var/log/wfwweb/wfwweb.log
Restart=always
WorkingDirectory=/opt/server

[Install]
WantedBy=Multi-user.target