[英]NoSuchMethodError when deploying Spring Boot to Weblogic
I've got a Spring Boot application running fine locally via the built in tomcat server but I'm having issues deploying it as a war file in Weblogic 12.2. 我有一个Spring Boot应用程序通过内置的tomcat服务器在本地运行良好但我在将其部署为Weblogic 12.2中的war文件时遇到了问题。 I've followed the "85.1 Create a deployable war file" section of the Spring Boot reference guide to build the war file, created a new Weblogic managed server to host it and followed the deployment install steps on Weblogic but get the below exception when clicking start "servicing all requests" on the deployment. 我按照Spring Boot参考指南的“85.1创建可部署的war文件”部分来构建war文件,创建了一个新的Weblogic托管服务器来托管它,并按照Weblogic上的部署安装步骤进行操作,但在单击时获得以下异常在部署上开始“服务所有请求”。 Any suggestions? 有什么建议么?
Dependencies section of build.gradle: build.gradle的依赖项部分:
dependencies {
compile fileTree(dir: 'lib', include: '*.jar')
compile(
'org.springframework.boot:spring-boot-starter-web:1.5.8.RELEASE',
'org.springframework.boot:spring-boot-devtools',
'org.springframework.boot:spring-boot-starter-jdbc',
'org.springframework.boot:spring-boot-starter-data-jpa',
'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.2',
'org.springframework.boot:spring-boot-starter-security',
'javax.servlet:javax.servlet-api:3.1.0'
)
testCompile(
'org.springframework.security:spring-security-test',
'org.springframework.boot:spring-boot-starter-test'
)
providedRuntime (
'org.springframework.boot:spring-boot-starter-tomcat'
)
}
Exception received from Weblogic when clicking start "servicing all requests": 单击开始“为所有请求提供服务”时从Weblogic收到异常:
Caused By: java.lang.NoSuchMethodError: org.springframework.web.context.support.StandardServletEnvironment.initPropertySources(Ljavax/servlet/ServletContext;Ljavax/servlet/ServletConfig;)V
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:162)
at weblogic.servlet.internal.WebAppServletContext.initContainerInitializer(WebAppServletContext.java:1420)
at weblogic.servlet.internal.WebAppServletContext.initContainerInitializers(WebAppServletContext.java:1359)
Loads more weblogic errors here.
My application entry point appears to be okay: 我的应用程序入口点似乎没问题:
@SpringBootApplication
public class Application extends SpringBootServletInitializer implements WebApplicationInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Add a weblogic deployment descriptor as said in spring-docs . 添加一个weblogic部署描述符,如spring-docs中所述。 Create a file named weblogic.xml
and add this code to the xml. 创建名为weblogic.xml
的文件,并将此代码添加到xml中。
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.slf4j</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>
Now put the weblogic.xml
file into WEB-INF
folder so that full path will be WEB-INF/weblogic.xml
. 现在将weblogic.xml
文件放入WEB-INF
文件夹,以便完整路径为WEB-INF/weblogic.xml
。
Update: Add a empty dispatcher-servlet.xml
to WEB-INF/
folder. 更新:将空的dispatcher-servlet.xml
添加到WEB-INF/
文件夹。
dispatcher-servlet.xml 调度员servlet.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
And your build.gradle
add dependency 并且你的build.gradle
添加依赖项
org.springframework.boot:spring-boot-starter-web
Also remove 也删除
providedRuntime (
'org.springframework.boot:spring-boot-starter-tomcat'
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.