{"id":19557433,"url":"https://github.com/ramostear/spring-boot-service-component","last_synced_at":"2026-06-13T19:34:25.913Z","repository":{"id":105269277,"uuid":"174881280","full_name":"ramostear/Spring-Boot-Service-Component","owner":"ramostear","description":"Service component tutorial source code by spring boot","archived":false,"fork":false,"pushed_at":"2019-03-10T21:33:30.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T08:15:31.387Z","etag":null,"topics":["spring-boot-tutorial"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ramostear.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-10T21:09:50.000Z","updated_at":"2019-03-10T21:33:31.000Z","dependencies_parsed_at":"2023-05-22T04:15:33.544Z","dependency_job_id":null,"html_url":"https://github.com/ramostear/Spring-Boot-Service-Component","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ramostear/Spring-Boot-Service-Component","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramostear%2FSpring-Boot-Service-Component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramostear%2FSpring-Boot-Service-Component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramostear%2FSpring-Boot-Service-Component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramostear%2FSpring-Boot-Service-Component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramostear","download_url":"https://codeload.github.com/ramostear/Spring-Boot-Service-Component/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramostear%2FSpring-Boot-Service-Component/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34298247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["spring-boot-tutorial"],"created_at":"2024-11-11T04:42:31.001Z","updated_at":"2026-06-13T19:34:25.883Z","avatar_url":"https://github.com/ramostear.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot（十二）— 服务组件\n\n所谓的服务组件（Service Component）— 就是用于处理系统业务逻辑的类，如果按照系统分层设计理论来划分，服务组件是位于业务层当中的类。在Spring Boot中，服务组件是一个被**@Service**注解进行注释的类，这些类用于编写系统的业务代码。在本章节中，将讲解如何创建并使用服务组件。\n\n在开始正文之前，先来看两段示例代码。使用服务组件之前，我们需要定义服务组件接口类，用于索引服务组件提供的服务，代码如下所示：\n\n```java\npublic interface UserService{\n    // TODO ...\n}\n```\n\n然后，需要使用**@Service**注解对服务组件接口实现类进行注释，演示代码如下：\n\n```java\n@Service(value=\"userService\")\npublic class UserServiceImpl implements UserService{\n    //TODO ...\n}\n```\n\n最后，使用**@Autowired**注解来自动引用服务组件，代码如下：\n\n```java\n@Controller\npublic class DemoController{\n    @Autowired\n    UserService userService;\n    //TODO ...\n}\n```\n\n在本次讲解中，我们依然以对用户的增、删、改、查为案例，将控制器中的业务方法迁移到服务组件中。\n\n-----\n如需查看本教程完整的内容，请访问[RT社圈](https://www.ramostear.com)或者点击下面的链接进行查看：\n[Spring Boot（十二）— 服务组件 | ramostear · 罗摩尔](https://www.ramostear.com/archive/spring-boot/post/service-component.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framostear%2Fspring-boot-service-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framostear%2Fspring-boot-service-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framostear%2Fspring-boot-service-component/lists"}