且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Weblogic服务器中部署Spring Boot应用程序时如何解决javax.validation的NoSuchMethodError问题?

更新时间:2023-09-12 18:50:22

最后,我能够解决问题.我没有意识到以下事实:如果从Weblogic的管理控制台中禁用了preferred-web-inf-classs,则weblogic会忽略weblogic.xml文件中指定的指令.

Finally I was able to solve the problem. I wasn't aware of the fact that if prefer-web-inf-classes is disabled from Weblogic admin console, then weblogic ignores the directive specified in weblogic.xml file.

摘自Oracle文档:>

preferred-web-inf-classes元素(如果设置为true)将导致优先于应用程序或系统类加载器中加载的类加载位于Web应用程序的WEB-INF目录中的类.默认值为false.在管理控制台中指定的值将优先于手动设置的值.

The prefer-web-inf-classes element, if set to true, will cause classes located in the WEB-INF directory of a Web application to be loaded in preference to classes loaded in the application or system classloader. The default value is false. A value specified in the Administration Console will take precedence over a value set manually.

因此,相反,我不得不在weblogic.xml文件中指定preferred-application-packages.这是文件的更新内容:

So, instead, I had to specify prefer-application-packages in weblogic.xml file. Here is the updated content of the file:

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <package-name>org.springframework.*</package-name>
        <package-name>org.hibernate.*</package-name>
        <package-name>javax.validation.*</package-name>
        <package-name>javax.validation.spi.*</package-name>
        <package-name>org.slf4j.*</package-name>
    </wls:prefer-application-packages>
    <wls:show-archived-real-path-enabled>true</wls:show-archived-real-path-enabled>
</wls:container-descriptor>

</weblogic-web-app>

此***帖子很有帮助.

感谢所有尝试提供帮助的人.

Thanks to everyone who tried to help.