Spring Data doesn't let Spring find JAXRS @Provider?

I am using Spring + Jersey to create an API service. Recently, I am trying to enable Spring Data on my server. I really haven't used any repositories in my working code, just add one line to your app.xml:

<jpa:repositories base-package="destiny.web" entity-manager-factory-ref="entityManagerFactoryApp" /> 

But! I noticed that my API is not working complaining " The message body writer is for the Java class xxx, and the class type Java xxx and the application type multimedia MIME / json were not found "

If I delete the line "jpa: repositories ..." in my xml, everything will be fine! and all provider classes are registered with Spring:

 {http://*:8080-1} Registering Spring bean, apiResultJsonWriter, of type destiny.web.api.ApiResultJsonWriter as a provider class {http://*:8080-1} Registering Spring bean, webApi, of type destiny.web.api.WebApi as a root resource class {http://*:8080-1} Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM' 

But if I add the line "jpa: repositories ..." to my XML, only the "root resource class" is logged:

 {http://*:8080-1} CDI support is enabled {http://*:8080-1} Using default applicationContext {http://*:8080-1} Registering Spring bean, webApi, of type destiny.web.api.WebApi as a root resource class {http://*:8080-1} Initiating Jersey application, version 'Jersey: 1.8 06/24/2011 12:17 PM' 

All JAXRS @Provider are missing!

I do not know if this is a Spring-Data bug? And how to solve it?

Environment:

 spring-3.1 jersey-core-1.8.jar jersey-server-1.8.jar jersey-spring-1.8.jar spring-data-jpa-1.0.3.RELEASE.jar spring-data-commons-core-1.1.0.RELEASE.jar 

server: resin-4.0.25

Related Dependencies:

 <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-spring</artifactId> <version>1.8</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> <version>1.0.3.RELEASE</version> </dependency> 

(I tried to add jersey-json but still didn't work)

+3
spring-data spring-data-jpa jersey jax-rs
Feb 14 2018-12-12T00:
source share
1 answer

You need to register packages containing classes annotated with @Provider

in Jersey 2, this is done by calling the package method in your ResourceConfig class.

I believe that there are also basic attributes that you can impose on a servlet. See Here Autodiscover JAX-RS Resources Using CXF in a Spring Application

0
Mar 05 '15 at 10:31
source share



All Articles