以下方法不存在:disableRegistry()

huangapple go评论76阅读模式
英文:

The following method did not exist: disableRegistry()

问题

我在我的应用程序中使用了Spring Boot和MongoDB。在启动应用程序时,它会产生以下错误:

***************************
APPLICATION FAILED TO START
***************************
Description:
尝试调用不存在的方法。该尝试发生在以下位置:org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:175)
以下方法不存在:
org.apache.tomcat.util.modeler.Registry.disableRegistry()V
方法的类,org.apache.tomcat.util.modeler.Registry,可以从以下位置获得:
jar:file:/C:/Users/djoni/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.37/tomcat-embed-core-8.5.37.jar!/org/apache/tomcat/util/modeler/Registry.class
类层次结构是从以下位置加载的:
org.apache.tomcat.util.modeler.Registry: file:/C:/Users/djoni/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.37/tomcat-embed-core-8.5.37.jar   
操作:
更正应用程序的类路径,使其包含兼容的 org.apache.tomcat.util.modeler.Registry 的单个版本。

我不明白具体需要做什么。我猜测一些版本不兼容。

在你的pom.xml文件中,你可以看到Tomcat的版本被指定为8.5.37。这个版本可能与Spring Boot的版本2.3.3.RELEASE不兼容,导致了上述错误。为了解决这个问题,你可以尝试升级Tomcat的版本,使其与你的Spring Boot版本兼容。你可以在pom.xml文件中将Tomcat的版本修改为Spring Boot推荐的版本。

另外,你可以检查你的应用程序类路径,确保只包含一个与org.apache.tomcat.util.modeler.Registry兼容的版本。

此外,你还可以在fitnesstudioApplication类中使用@SpringBootApplication注解,它标志着一个Spring Boot应用程序的入口点。在这个类中,你还需要继承SpringBootServletInitializer类,以支持war部署。

这些步骤应该可以帮助你解决这个错误。

英文:

I use Spring Boot and MongoDB in my application. When starting the application, it gives the following error

***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:      org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:175)
The following method did not exist:
    org.apache.tomcat.util.modeler.Registry.disableRegistry()V
The method's class, org.apache.tomcat.util.modeler.Registry, is available from the following locations:
    jar:file:/C:/Users/djoni/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.37/tomcat-embed-core-8.5.37.jar!/org/apache/tomcat/util/modeler/Registry.class
The class hierarchy was loaded from the following locations:
    org.apache.tomcat.util.modeler.Registry: file:/C:/Users/djoni/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.37/tomcat-embed-core-8.5.37.jar   

Action:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.tomcat.util.modeler.Registry

I do not understand what exactly needs to be done.
I assume some versions are not compatible

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.evghenii</groupId>
    <artifactId>fitnesstudio</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>fitnesstudio</name>
    <description> Spring Boot und Mongo</description>

    <properties>
        <java.version>1.8</java.version>
        <tomcat.version>8.5.37</tomcat.version>
    </properties>

    <dependencies>    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency>    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>    
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>       
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.11.Final</version>
        </dependency>    
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.1.2.Final</version>
        </dependency>            
         <dependency>
             <groupId>org.hibernate.ogm</groupId>
             <artifactId>hibernate-ogm-mongodb</artifactId>
             <version>5.4.0.Final</version>
         </dependency>          
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency> 
    </dependencies>  
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

Application

@SpringBootApplication
public class FitnesstudioApplication extends SpringBootServletInitializer {   
    public static void main(String[] args) {
        SpringApplication.run(FitnesstudioApplication.class, args);
    }

how to fix this error?

答案1

得分: 1

我遇到了同样的问题。

解决方案:从 mongodb 依赖中移除版本信息。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

更新后的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.evghenii</groupId>
    <artifactId>fitnesstudio</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>fitnesstudio</name>
    <description>Spring Boot und Mongo</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <!-- 其他依赖项 ... -->

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.4.11.Final</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>6.1.2.Final</version>
        </dependency>

        <!-- 其他依赖项 ... -->

        <dependency>
            <groupId>org.hibernate.ogm</groupId>
            <artifactId>hibernate-ogm-mongodb</artifactId>
            <version>5.4.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency>

        <!-- 其他依赖项 ... -->

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

注:你可以看到一个 mongodb 异常。这不会在你的系统上出现,因为你在系统上启动了 mongod 进程。

英文:

I got the same issue.

Resolution : Remove the version from mongodb dependency.

&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
&lt;/dependency&gt;

Updated pom.xml :

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;parent&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
&lt;version&gt;2.3.3.RELEASE&lt;/version&gt;
&lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
&lt;/parent&gt;
&lt;groupId&gt;com.evghenii&lt;/groupId&gt;
&lt;artifactId&gt;fitnesstudio&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;name&gt;fitnesstudio&lt;/name&gt;
&lt;description&gt; Spring Boot und Mongo&lt;/description&gt;
&lt;properties&gt;
&lt;java.version&gt;1.8&lt;/java.version&gt;
&lt;/properties&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
&lt;scope&gt;runtime&lt;/scope&gt;
&lt;optional&gt;true&lt;/optional&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
&lt;artifactId&gt;lombok&lt;/artifactId&gt;
&lt;optional&gt;true&lt;/optional&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;exclusions&gt;
&lt;exclusion&gt;
&lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
&lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
&lt;/exclusion&gt;
&lt;/exclusions&gt;
&lt;/dependency&gt;
&lt;!--  &lt;dependency&gt;
&lt;groupId&gt;org.powermock&lt;/groupId&gt;
&lt;artifactId&gt;powermock-module-junit4&lt;/artifactId&gt;
&lt;version&gt;2.0.7&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;--&gt;
&lt;!-- &lt;dependency&gt;
&lt;groupId&gt;org.powermock&lt;/groupId&gt;
&lt;artifactId&gt;powermock-api-mockito2&lt;/artifactId&gt;
&lt;version&gt;2.0.7&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.aspectj&lt;/groupId&gt;
&lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;
&lt;version&gt;1.9.2&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.hibernate&lt;/groupId&gt;
&lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
&lt;version&gt;5.4.11.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.hibernate.validator&lt;/groupId&gt;
&lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
&lt;version&gt;6.1.2.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;!-- &lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;!--   &lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;!--  &lt;dependency&gt;
&lt;groupId&gt;javax.mail&lt;/groupId&gt;
&lt;artifactId&gt;mail&lt;/artifactId&gt;
&lt;version&gt;1.4.7&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;!-- &lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-core&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-context&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;!--   &lt;dependency&gt;
&lt;groupId&gt;javax.servlet&lt;/groupId&gt;
&lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
&lt;version&gt;3.1.0&lt;/version&gt;
&lt;scope&gt;compile&lt;/scope&gt;
&lt;/dependency&gt;--&gt;
&lt;!--      &lt;dependency&gt;
&lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
&lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
&lt;version&gt;2.10.3&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
&lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
&lt;version&gt;2.10.3&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;!--   &lt;dependency&gt;
&lt;groupId&gt;com.jayway.jsonpath&lt;/groupId&gt;
&lt;artifactId&gt;json-path-assert&lt;/artifactId&gt;
&lt;version&gt;2.4.0&lt;/version&gt;
&lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;com.jayway.jsonpath&lt;/groupId&gt;
&lt;artifactId&gt;json-path&lt;/artifactId&gt;
&lt;version&gt;2.4.0&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;!--
&lt;dependency&gt;
&lt;groupId&gt;javax.el&lt;/groupId&gt;
&lt;artifactId&gt;javax.el-api&lt;/artifactId&gt;
&lt;version&gt;3.0.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.glassfish&lt;/groupId&gt;
&lt;artifactId&gt;javax.el&lt;/artifactId&gt;
&lt;version&gt;3.0.0&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;!--   &lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
&lt;version&gt;5.2.5.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
--&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.hibernate.ogm&lt;/groupId&gt;
&lt;artifactId&gt;hibernate-ogm-mongodb&lt;/artifactId&gt;
&lt;version&gt;5.4.0.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;!--&lt;dependency&gt;
&lt;groupId&gt;org.jboss.narayana.jta&lt;/groupId&gt;
&lt;artifactId&gt;narayana-jta&lt;/artifactId&gt;
&lt;version&gt;5.9.2.Final&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
&lt;version&gt;2.3.3.RELEASE&lt;/version&gt;
&lt;/dependency&gt;
&lt;!--    &lt;dependency&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-starter-jersey&lt;/artifactId&gt;
&lt;version&gt;2.3.2.RELEASE&lt;/version&gt;
&lt;/dependency&gt;--&gt;
&lt;/dependencies&gt;
&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
&lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
&lt;/project&gt;

SCREENSHOT :

以下方法不存在:disableRegistry()

Note: You can see one mongodb exception. This will not come on your system as you start the mongod process on your system.

huangapple
  • 本文由 发表于 2020年9月23日 19:22:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/64026869.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定