1、集成jersey后访问接口报404
通过注解初始化jersey代码:
//@Component //@ApplicationPath("/webapi/*") public class AppResourceConfig extends ResourceConfig { public AppResourceConfig() { packages("com.zgl.springboot.rs"); register(MultiPartFeature.class); } }
修改为在Application后,可正常访问:
@Bean public ServletRegistrationBean jersetServlet(){ ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/webapi/*"); // our rest resources will be available in the path /webapi/* registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, AppResourceConfig.class.getName()); return registration; }
2、发布到独立tomcat时,报错
java.lang.NoSuchMethodError:org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
原代码:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
修改后代码:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.14.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
3、发布到独立tomcat时,报错