{"id":21154957,"url":"https://github.com/forge/springboot-addon","last_synced_at":"2025-09-10T19:35:29.094Z","repository":{"id":52315167,"uuid":"83330717","full_name":"forge/springboot-addon","owner":"forge","description":"SpringBoot Addon","archived":false,"fork":false,"pushed_at":"2023-11-28T20:57:01.000Z","size":275,"stargazers_count":4,"open_issues_count":2,"forks_count":5,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-19T06:48:37.009Z","etag":null,"topics":["addon","ide","jboss-forge","spring-boot"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/forge.png","metadata":{"files":{"readme":"README.adoc","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-27T16:18:03.000Z","updated_at":"2023-08-29T10:45:02.000Z","dependencies_parsed_at":"2024-11-19T06:46:57.602Z","dependency_job_id":null,"html_url":"https://github.com/forge/springboot-addon","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forge%2Fspringboot-addon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forge%2Fspringboot-addon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forge%2Fspringboot-addon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forge%2Fspringboot-addon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forge","download_url":"https://codeload.github.com/forge/springboot-addon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225536067,"owners_count":17484764,"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":["addon","ide","jboss-forge","spring-boot"],"created_at":"2024-11-20T11:08:49.532Z","updated_at":"2024-11-20T11:08:50.164Z","avatar_url":"https://github.com/forge.png","language":"Java","readme":":idprefix: id_\n:source-highlighter: pygments\n\n== Spring Boot Forge addon\n\nimage:https://forge.ci.cloudbees.com/buildStatus/icon?job=springboot-addon[\"Build Status\", link=\"https://forge.ci.cloudbees.com/job/springboot-addon\"]\nimage:http://img.shields.io/:license-EPL-blue.svg[\"License\", link=\"https://www.eclipse.org/legal/epl-v10.html\"]\nimage:https://maven-badges.herokuapp.com/maven-central/org.jboss.forge.addon/spring-boot/badge.svg[\"Maven Central\", link=\"https://maven-badges.herokuapp.com/maven-central/org.jboss.forge.addon/spring-boot\"]\n\nThis addon provides *standalone* functionality, and *exports services* for use in other addons.\n\n=== Prerequisites\n\n- JBoss Forge \u003e= 3.7\n- Java 8\n\n=== Installation\n\nFrom Forge CLI:\n\n[source,shell]\n----\naddon-install-from-git --url https://github.com/forge/springboot-addon.git\n----\n\n=== Depends on\n[options=\"header\"]\n|===\n|Addon |Exported |Optional\n\n|ui\n|no\n|no\n\n|projects\n|no\n|no\n\n|maven\n|no\n|no\n\n|parser-java\n|no\n|no\n\n|parser-json\n|no\n|no\n\n|parser-yaml\n|no\n|no\n\n|cdi\n|no\n|no\n\n|scaffold\n|no\n|no\n\n|cdi\n|no\n|no\n\n|rest-client\n|no\n|no\n\n|templates\n|no\n|no\n|===\n\n== Features\nThe Spring Boot addon reuses standard commands adding options and/or new commands only when required.\n\nSpring Boot Project type::\n\nIf you want to create a new Spring Boot starter project as you can do using `start.spring.io`, simply use the `project-new` command where you include `spring-boot` as project type.\nThe command will issue a REST call against `start.spring.io`, will get a zip file containing the maven project created according to the parameters passed.\n+\nThe content of this file will be unzipped locally under the directory as defined by the `--named` parameter.\n+\nWhen no Spring Boot starters / dependencies are defined, then `start.spring.io` will return a project containing\nthe `spring-boot-starter` and `spring-boot-starter-test` maven artifacts using the default Spring version which is `1.5.3.RELEASE`\n+\n----\nproject-new --named example --type spring-boot\n----\n\nStarter Version and dependencies::\n\nYou can specify which Spring Boot starter version you want to use when the project will be created using the `--spring-boot-version` option like also the starters to be included within the pom.xml file\nwith the `--dependencies` option, which is defined as a space-separated list of dependencies.\n+\n----\nproject-new --named example --type spring-boot  --spring-boot-version 1.4.3.RELEASE --dependencies actuator web\n----\n+\nNOTE: By pressing tab after typing `--dependencies` option will result in Forge retrieving the list of\navailable dependencies that can then be auto-completed.\n\nOne line::\n\nYou can create your project using one `command line` with the required parameters:\n+\n----\nproject-new --named demo --version 1.0 --top-level-package org.demo --type spring-boot --spring-boot-version 1.4.3.RELEASE --dependencies actuator elasticsearch\n----\n\nPersistence setup::\n\nWhenever it is required to use the `spring-boot-starter-data-jpa` starter and to setup the Hibernate provider, then you can use the following command\n+\n----\njpa-setup\n----\n+\nThe persistence provider will be configured with the appropriate driver and sane default settings.\nAlso, by default, if no database is specified, H2 database \"in-memory\" is used.\n+\nTo configure by example mysql, pass these parameters:\n+\n----\njpa-setup --db-type MYSQL --database-url jdbc:mysql://mysql:3306/catalogdb --username mysql --password mysql\n----\nand the command will populate accordingly the Spring jpa and datasource keys\n+\n----\nspring.datasource.url=jdbc\\:mysql\\://mysql\\:3306/catalogdb\nspring.datasource.username=mysql\nspring.datasource.password=mysql\n\nspring.jpa.properties.hibernate.transaction.flush_before_completion=true\nspring.jpa.properties.hibernate.show_sql=true\nspring.jpa.properties.hibernate.format_sql=true\nspring.jpa.properties.hibernate.hbm2ddl.auto=create-drop\nspring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect\n----\n\nEntities \u0026 fields::\n\nIn order to create an `Entity` representing the Java class to be mapped with a Database table and its fields, use this command\n+\n----\njpa-new-entity --named Album\njpa-new-field --named artist\njpa-new-field --named title\njpa-new-field --named description --length 2000\njpa-new-field --named price --type java.lang.Float\njpa-new-field --named publication_date --type java.util.Date --temporalType DATE\n----\n+\nThen a new JPA entity will be created, fields included.\n+\nThe command also generates a `PagingAndSortingRepository` implementation that can be used with the\n`spring-boot-starter-data-rest` starter to automatically expose a REST endpoint for this entity:\n+\n[source,java]\n----\nimport org.springframework.data.repository.PagingAndSortingRepository;\n\npublic interface AlbumRepository extends PagingAndSortingRepository\u003cAlbum, Long\u003e {\n}\n----\nFor more details on how to access JPA entities RESTfully with Spring Boot, please take a look at\nhttps://spring.io/guides/gs/accessing-data-rest/[https://spring.io/guides/gs/accessing-data-rest/].\n`PagingAndSortingRepository` is described in the \"Create a Person repository\" section of that document.\n\nExpose your entities as REST endpoints using JAX-RS::\n\nThe command `rest-generate-endpoints-from-entities` will generate JAX-RS RESTful endpoints based on JPA entities. The behavior\nis customized for Spring Boot and defaults to use the Apache CXF stack which supports the `JAX-RS` specification and is packaged within the `cxf-spring-boot-starter-jaxrs` starter.\n+\nThe Spring Boot mode is activated by using the `SPRING_BOOT_JPA_ENTITY` generator:\n+\n----\nrest-generate-endpoints-from-entities --generator SPRING_BOOT_JPA_ENTITY --targets ...\n----\n+\nExample of code generated:\n+\n[source,java]\n----\n@Path(\"/catalogs\")\n@Component\n@Transactional\npublic class CatalogEndpoint {\n\t@PersistenceContext\n\tprivate EntityManager em;\n\n\t@POST\n\t@Consumes(\"application/json\")\n\tpublic Response create(Catalog entity) {\n\t\tem.persist(entity);\n\t\treturn Response.created(\n\t\t\t\tUriBuilder.fromResource(CatalogEndpoint.class)\n\t\t\t\t\t\t.path(String.valueOf(entity.getId())).build()).build();\n\t}\n----\n+\nWARNING: Note that the resources derived from the JPA entities are currently limited to JSON representations (with the Jackson JSON stack).\n\nGenerate a REST endpoint::\n\nThe project generated by `start.spring.io` is pretty lean as it only includes a `DemoApplication` class annotated\nwith the `@SpringBootApplication` annotation performing the Spring Boot magic and an `application.properties` file.\nBy using the following command you will be able to generate a REST controller class exposing a `/greeting` endpoint and generating a response using the `Greeting` model class.\n+\nTo create the controller, issue this command where the name passed will be used to create the Java class under the package name of the project\n+\n[source,java]\n----\nrest-new-endpoint --named GreetingController\n----\n+\nTo define the path to access the REST endpoints, extend the command with the `--path` parameter\n+\n[source,java]\n----\nrest-new-endpoint --named GreetingController --path api\n----\n\nSupport CORS::\n\nThe `rest-new-cross-origin-resource-sharing-filter` command will create a CORS filter so that cross-origin requests are allowed.\nThe filter is also annotated so that it is automatically recognized by the Apache CXF implementation when it will start to scan the classes to check if some contain\nthe annotation `@Component`.\n+\nExample:\n+\n[source,java]\n----\n@Provider\n@Component\npublic class NewCrossOriginResourceSharingFilter\n\t\timplements\n\t\t\tContainerResponseFilter {\n\n\t@Override\n\tpublic void filter(ContainerRequestContext request,\n\t\t\tContainerResponseContext response) {\n\t\tresponse.getHeaders().putSingle(\"Access-Control-Allow-Origin\", \"*\");\n\t\tresponse.getHeaders().putSingle(\"Access-Control-Expose-Headers\",\n\t\t\t\t\"Location\");\n\t\tresponse.getHeaders().putSingle(\"Access-Control-Allow-Methods\",\n\t\t\t\t\"GET, POST, PUT, DELETE\");\n\t\tresponse.getHeaders()\n\t\t\t\t.putSingle(\"Access-Control-Allow-Headers\",\n\t\t\t\t\t\t\"Content-Type, User-Agent, X-Requested-With, X-Requested-By, Cache-Control\");\n\t\tresponse.getHeaders().putSingle(\"Access-Control-Allow-Credentials\",\n\t\t\t\t\"true\");\n\t}\n}\n----\n\nDefine the starters to be selected::\n\nIf you want to restrict the list of dependencies/starters to be selected (or to use according to your needs) when you will create your project,\npass the reference of this file using the following ENV variable `SPRING_BOOT_CONFIG_FILE` to the command `project-new`\n+\n[source,java]\n----\nexport SPRING_BOOT_CONFIG_FILE=file:///path/to/your/spring-boot-application.yaml\n\nproject-new --type spring-boot --spring-boot-version 1.4.3.RELEASE --dependencies ...\n----\n+\nAn example of such a file is link:src/main/resources/spring-boot-application.yaml[available]. Only the dependencies section will be used to\npopulate the pom.xml.\n\nNOTE: You can create such a file according to the convention defined by http://docs.spring.io/initializr/docs/current/reference/htmlsingle/#configuration-format[Spring Initialzr]\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforge%2Fspringboot-addon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforge%2Fspringboot-addon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforge%2Fspringboot-addon/lists"}