java – WebLogic – 在WebLogic Server中部署SpringBoot war

前端之家收集整理的这篇文章主要介绍了java – WebLogic – 在WebLogic Server中部署SpringBoot war前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我试图将一个简单的SpringBoot应用程序转换为在WebLogic中部署.它在buildin TomCat服务器中运行良好.然后我对它进行更改并创建一个新的war文件.当我尝试部署war文件时,我收到此错误.

WebLogic控制台错误

WebLogic Console Error

用于web.xml的Servlet初始化程序

package demo;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SampleStsApplication.class);
    }

}

Application.java文件

package demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.WebApplicationInitializer;

@SpringBootApplication
@Configuration
@ComponentScan
@EnableAutoConfiguration
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);
    }

}

的pom.xml

weblogic.xml文件

     < [ACTIVE] ExecuteThread:'4'表示队列:'weblogic.kernel.Default(self-tuning)'> <> <> < 144201069 8389>

    at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:161)
    at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:327)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.getDescriptorBeanFromReader(AbstractDescriptorLoader2.java:817)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:415)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:779)
    at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:792)
    at weblogic.servlet.internal.fragment.WebFragmentLoader.getWebFragmentBean(WebFragmentLoader.java:36)
    at weblogic.servlet.internal.fragment.WebFragmentManager.prepareForTopologicalSort(WebFragmentManager.java:164)
    at weblogic.servlet.internal.fragment.WebFragmentManager.sortRelatively(WebFragmentManager.java:152)
    at weblogic.servlet.internal.fragment.WebFragmentManager.sortFragments(WebFragmentManager.java:109)
    at weblogic.servlet.internal.fragment.WebFragmentManager.

引起:com.bea.xml.XmlException:无法加载与e = web-fragment相对应的java类型@ http://xmlns.jcp.org/xml/ns/javaee
        在com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(UnmarshalResult.java:371)
        在com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:326)
        在com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:336)
        在com.bea.staxb.runtime.internal.UnmarshalResult.determineRootType(UnmarshalResult.java:317)
        在com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalDocument(UnmarshalResult.java:168)
        在com.bea.staxb.runtime.internal.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:67)
        在weblogic.descriptor.internal.MarshallerFactory $1.createDescriptor(MarshallerFactory.java:150)
        ……还有133个

最佳答案
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html#howto-weblogic表示您需要让@SpringBootApplication类直接实现WebApplicationInitializer.似乎WebLogic的逻辑使用反射(错误地)而不是执行instanceof检查.

同一页面还提醒您需要wls:如果您使用logback,则需要org.slf4j的prefer-application-packages(我不知道为什么,也许jar不兼容).

猜你在找的Springboot相关文章