Springboot项目jdk升级11后遇到的一些问题(javax.jws.WebService报错)

项目场景:

该项目之前使用cxf整合过webservice,现在项目需要把jdk由1.8升级到11,记录遇到的一些问题。


升级就是pom文件中java版本指定到11

	<properties>
		<java.version>11</java.version>
		<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
	</properties>

	<parent>
		<groupId>com.telecom.platform</groupId>
		<artifactId>app-support</artifactId>
		<version>20201001-2.3.4</version>
	</parent>

一些常见的版本升级报错

  • findOne() 改成 findById().get()
  • new PageRequest(0, 1) 改成 PageRequest.of(0, 1)
  • new Sort() 改成 Sort.by()

1.找不到包javax.jws.WebService

应该是高版本的jdk中去掉了,直接引入即可:

<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>javax.jws-api</artifactId>
    <version>1.1</version>
</dependency>

2.找不到包org.springframework.boot.context.embedded.ServletRegistrationBean;

ServletRegistrationBean这个类在新版本中更换了包,直接去掉之前的,引入新包即可。

import org.springframework.boot.web.servlet.ServletRegistrationBean;

3.启动报错Error creating bean with name ‘tomcatServletWebServerFactory’ defined in class path resource

CxfConfig中dispatcherServlet,大佬说高版本不需要这么申明,注释后直接在配置文件中加 cxf.path=/test,测试可行。另一种就是在@Bean后面加上(name=“cxfServlet”)也可以。

@Bean(name="cxfServlet")
public ServletRegistrationBean dispatcherServlet() {
	return new ServletRegistrationBean(new CXFServlet(), "/test/*");
}

4.启动报错nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/exc/InputCoercionException

jackson的两个包的版本需要从原来的2.9.9升级到2.10.1

		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.10.1</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-annotations</artifactId>
			<version>2.10.1</version>
		</dependency>

至此,jdk升级完成,项目可以正常运行和访问wsdl。

你可能感兴趣的:(java,java,spring,boot,maven)