Commit beb817e4 authored by liboyang's avatar liboyang

整合jersey

parent 464a5ac6
package com.yx_project.start;
import com.yx_project.start.config.JerseyConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.glassfish.jersey.servlet.ServletProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
public class YxRefactoringApplication {
@Bean
public ServletRegistrationBean jerseyServlet() {
ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/rest/*");
registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS,
JerseyConfig.class.getName());
return registration;
}
public static void main(String[] args) {
SpringApplication.run(YxRefactoringApplication.class, args);
}
......
......@@ -3,19 +3,22 @@ package com.yx_project.start.api;
import com.yx_project.start.entity.SystemUserEntity;
import com.yx_project.start.service.impl.SystemUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;
@RestController
@Path("user")
public class SystemUserApi {
@Autowired
private SystemUserServiceImpl userService;
@RequestMapping("list")
@GET
@Path("list")
@Produces(MediaType.APPLICATION_JSON)
public List<SystemUserEntity> list(){
List<SystemUserEntity> list = userService.findAllUser();
return list;
......
package com.yx_project.start.config;
import com.yx_project.start.api.SystemUserApi;
import org.glassfish.jersey.server.ResourceConfig;
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
register(SystemUserApi.class);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment