Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conversions table between Spring annotations and Quarkus ones #5437

Merged
merged 2 commits into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/src/main/asciidoc/spring-di.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,50 @@ Spring classes and annotations are only used for reading metadata and / or are u
What that means for end users, is that adding arbitrary Spring libraries will not have any effect. Moreover Spring infrastructure
classes (like `org.springframework.beans.factory.config.BeanPostProcessor` for example) will not be executed.

== Conversion Table

The following table shows how Spring DI annotations can be converted to CDI and / or MicroProfile annotations.

|===
|Spring |CDI / MicroProfile |Comments

|@Autowired
|@Inject
|

|@Qualifier
|@Named
|

|@Value
|@ConfigProperty
|@ConfigProperty doesn't support an expression language the way @Value does, but makes the typical use cases much easier to handle

|@Component
|@Singleton
|By default Spring stereotype annotations are singleton beans

|@Service
|@Singleton
|By default Spring stereotype annotations are singleton beans

|@Repository
|@Singleton
|By default Spring stereotype annotations are singleton beans

|@Configuration
|@ApplicationScoped
|In CDI a producer bean isn't limited to the application scope, it could just as well be @Singleton or @Dependent

|@Bean
|@Produces
|

|@Scope
|
|Doesn't have a one-to-one mapping to a CDI annotation. Depending on the value of @Scope, one of the @Singleton, @ApplicationScoped, @SessionScoped, @RequestScoped, @Dependent could be used
|===

== More Spring guides

Quarkus supports additional Spring compatibility features. See the following guides for more details:
Expand Down
48 changes: 48 additions & 0 deletions docs/src/main/asciidoc/spring-web.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,54 @@ Spring classes and annotations are only used for reading metadata and / or are u
What that means for end users, is that adding arbitrary Spring libraries will not have any effect. Moreover Spring infrastructure
classes (like `org.springframework.beans.factory.config.BeanPostProcessor` for example) will not be executed.

== Conversion Table

The following table shows how Spring Web annotations can be converted to JAX-RS annotations.

|===
|Spring |JAX-RS |Comments

|@RequestController
|
|There is no equivalent in JAX-RS. Annotating a class with @Path suffices

|@RequestMapping(path="/api")
|@Path("/api")
|

|@RequestMapping(consumes="application/json")
|@Consumes("application/json")
|

|@RequestMapping(produces="application/json")
|@Produces("application/json")
|

|@RequestParam
|@QueryParam
|

|@PathVariable
|@PathParam
|

|@RequestBody
|
|No equivalent in JAX-RS. Method parameters corresponding to the body of the request are handled in JAX-RS without requiring any annotation

|@RestControllerAdvice
|
|No equivalent in JAX-RS

|@ResponseStatus
|
|No equivalent in JAX-RS

|@ExceptionHandler
|
|No equivalent annotation in JAX-RS. Exceptions are handled by implementing `javax.ws.rs.ext.ExceptionMapper`
|===

== More Spring guides

Quarkus support has more Spring compatibility features. See the following guides for more details:
Expand Down