{"id":25641952,"url":"https://github.com/joylau/joylau-springboot-daemon-windows","last_synced_at":"2025-04-15T03:29:53.062Z","repository":{"id":51292892,"uuid":"102065710","full_name":"JoyLau/joylau-springboot-daemon-windows","owner":"JoyLau","description":"将SpringBoot应用制作为Windows Services服务 | make spring boot module to windows services","archived":false,"fork":false,"pushed_at":"2019-04-18T07:17:34.000Z","size":52,"stargazers_count":70,"open_issues_count":10,"forks_count":39,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-12T04:39:41.326Z","etag":null,"topics":["services","spring-boot","windows"],"latest_commit_sha":null,"homepage":"http://image.joylau.cn/blog/joylau-springboot-daemon-service-video.mp4","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoyLau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-01T02:36:09.000Z","updated_at":"2025-04-09T02:32:58.000Z","dependencies_parsed_at":"2022-09-12T10:41:53.086Z","dependency_job_id":null,"html_url":"https://github.com/JoyLau/joylau-springboot-daemon-windows","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoyLau%2Fjoylau-springboot-daemon-windows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoyLau%2Fjoylau-springboot-daemon-windows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoyLau%2Fjoylau-springboot-daemon-windows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoyLau%2Fjoylau-springboot-daemon-windows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoyLau","download_url":"https://codeload.github.com/JoyLau/joylau-springboot-daemon-windows/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249000940,"owners_count":21196346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["services","spring-boot","windows"],"created_at":"2025-02-23T05:16:37.107Z","updated_at":"2025-04-15T03:29:53.032Z","avatar_url":"https://github.com/JoyLau.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 一款将 SpringBoot 项目做成Windows Service 的 Maven 插件\n\n\u003e\u003e 包括但不限于 SpringBoot ,任何打成 java jar 包运行的 Maven 项目都可以使用\n\n## 编写初衷\n- 公司有个项目\n- Java 部分的全部使用的是SpringBoot\n- 该项目的部署环境是 Windows\n- 公司想把 各个 SpringBoot 的模块托管一下\n- 托管的使用方式要简单，易用，测试在打包部署的时候要很容易上手\n- 期间尝试过 Spring Boot Admin 和 Jenkins,都说不好用...\n- 于是就想着 将Spring Boot 的服务制作成 Windows 服务，这样基本上会操作电脑的人都会使用了，够简单易用的了吧\n- 花了一上午时间将其中一个 Spring Boot 模块制作成了 Windows Service\n- 发现再做其他的模块的时候，很多工作都是重复的，心想着能够将这个功能提取出来就好了\n- 于是就写了这个 Maven 插件\n\n\n## 使用演示地址：\nMP4 ： http://image.joylau.cn/blog/joylau-springboot-daemon-service-video.mp4\n\n## 1.1.RELEASE\n- 增加 java 运行时 vm 参数和程序参数的分别配置\n- bat 文件会自动申请管理员权限,不需要手动右键以管理员身份运行\n\n## 怎么使用？\n- 使用方法很简单，和普通的 Maven 插件一样使用就可以了，如下\n``` xml\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003ecn.joylau.code\u003c/groupId\u003e\n            \u003cartifactId\u003ejoylau-springboot-daemon-windows\u003c/artifactId\u003e\n            \u003cversion\u003e1.1.RELEASE\u003c/version\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cid\u003emake-win-service\u003c/id\u003e\n                    \u003cphase\u003epackage\u003c/phase\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003emake-win-service\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n```\n\n注意：\n 1. 这里的 phase 写的是 package,意思是该插件在 mvn package 的时候调用,你也可以根据不同的需求来更改，比如 install, test等等\n 2. goal 写 make-win-service 就可以了，不需要改动\n 3. 一般情况下我们的SpringBoot项目会有其他父项目，这时打包会使用 spring-boot-maven-plugin 插件的 repackage,这样的情况的话，请将该插件放置最后面,否则服务运行的话将提示没有主属性\n \n- 在你的项目中按照以上的方式引入插件后，现在可以 打包了\n``` \n    mvn package\n```\n\n打包过程中，看到如下日志信息，便制作成功了：\n![joylau-springboot-daemon-windows-package-info](http://image.joylau.cn/blog/joylau-springboot-daemon-windows-package-info.jpg)\n\n此时，在你项目的target目录下会生成一个 jar 包名字 一样的压缩包\n进入文件夹，解压这个压缩包，你会看见如下内容的文件\n![joylau-springboot-daemon-windows-package-file](http://image.joylau.cn/blog/joylau-springboot-daemon-windows-package-file.jpg)\n注意：\n 1. 5个 bat 文件，双击运行无反应时,请右键以管理员的身份运行\n 2. 各文件的文件名无特殊情况，不需要修改\n 3. 一旦安装成了 Windows 服务，目录下的文件就不要移动了\n 4. 命令运行时，可能会提示安装.NET,安装完成就可运行命令了，不过现在大部分的 Windows 服务器或者个人电脑都会默认安装了.NET,没有的话启用一下就好了，如下图：\n ![joylau-springboot-daemon-windows-.NET](http://image.joylau.cn/blog/joylau-springboot-daemon-windows-.net.jpg)\n 5. 运行各个命令是注意提示信息，例如卸载完服务都的状态为NonExistent，刚安装完服务后的状态为Stopped，服务成功启动的状态为Started...等等\n ![joylau-springboot-daemon-windows-service-status](http://image.joylau.cn/blog/joylau-springboot-daemon-service-status.jpg)\n\n\n## 扩展参数\n想要在服务启动时添加自定义参数,如 SpringBoot 的配置参数或者 JMV 参数？\n像如下配置即可：\n``` xml\n    \u003cplugin\u003e\n        \u003cgroupId\u003ecn.joylau.code\u003c/groupId\u003e\n        \u003cartifactId\u003ejoylau-springboot-daemon-windows\u003c/artifactId\u003e\n        \u003cversion\u003e1.1.RELEASE\u003c/version\u003e\n        \u003cexecutions\u003e\n            \u003cexecution\u003e\n                \u003cid\u003emake-win-service\u003c/id\u003e\n                \u003cphase\u003epackage\u003c/phase\u003e\n                \u003cgoals\u003e\n                    \u003cgoal\u003emake-win-service\u003c/goal\u003e\n                \u003c/goals\u003e\n            \u003c/execution\u003e\n        \u003c/executions\u003e\n        \u003cconfiguration\u003e\n            \u003cvmOptions\u003e-Xms1024m -Xmx2048m\u003c/vmOptions\u003e\n            \u003cprogramArguments\u003e--server.port=9090\u003c/programArguments\u003e\n        \u003c/configuration\u003e\n    \u003c/plugin\u003e\n```\n\n上面配置了JVM 参数 和 Spring Boot 应用的启动端口\n\n## 使用注意\n- 打包使用过程中需要联网\n- 文档中有些图片可能看不到，再次刷新下页面就可以\n- 服务的id为artifactId，服务的名称为artifactId+version，服务的描述为description\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoylau%2Fjoylau-springboot-daemon-windows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoylau%2Fjoylau-springboot-daemon-windows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoylau%2Fjoylau-springboot-daemon-windows/lists"}