简体   繁体   English

尝试构建 Rest 服务时 Spring Boot 失败

[英]Spring boot failed when trying to build a Rest service

Good afternoon I am trying to generate a Rest service with java spring boot, but when trying to execute the jar I get the following error, which is giving me a headache and I don't know what it is specifically:下午好,我正在尝试使用 java spring boot 生成 Rest 服务,但是在尝试执行 jar 时出现以下错误,这让我很头疼,我不知道具体是什么:

java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;)V at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$1.(AbstractRepositoryConfigurationSourceSupport.java:67) at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.getConfigurationSource(AbstractRepositoryConfigurationSourceSupport.java:66) at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:58) at org.springframework.context.annotation.ImportBeanDefinitionRegistrar.registerBeanDefinitions(ImportBeanDefinitionRegistrar.java:86) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsF java.lang.NoSuchMethodError: org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core /env/Environment;)V 在 org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$1.(AbstractRepositoryConfigurationSourceSupport.java:67) 在 org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.getConfigurationSource(AbstractRepositoryConfigurationSourceSupport.java:67) org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:58) 在 org.springframework.context.annotation.ImportBeanDefinitionRegistrar.registerBeanDefinitions(ImportBeanDefinitionRegistrar.java:86) 在 org.springframework.context.annotation.ImportBeanDefinitionRegistrar.registerBeanDefinitions(ImportBeanDefinitionRegistrar.java:86) 在 org.spring. lambda$loadBeanDefinitionsF romRegistrars$1(ConfigurationClassBeanDefinitionReader.java:385) at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:384) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionReg romRegistrars$1(ConfigurationClassBeanDefinitionReader.java:385) at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java.384) at orgtextframework.con annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) at org.springframework.context.annotation.processConfigurationClassPost3or org.springframework.context.annotation.ConfigurationClassBeanDefinition(ConfigurationClassBeanDefinitionReader.java:120)在 org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) 在 org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionReg istryPostProcessors(PostProcessorRegistrationDelegate.java:275) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) at com.example.consul istryPostProcessors(PostProcessorRegistrationDelegate.java:275) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors)atworkBean. .context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) 在 org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) 在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java) :752) 在 org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:295) 在 org.springframework.boot.SpringApplication.run(SpringApplication. java:1112) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) 在 com.example.consul ta.SpringBootSoapApp.main(SpringBootSoapApp.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ta.SpringBootSoapApp.main(SpringBootSoapApp.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImplating.Invoke(Native Method) java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

java.lang.NoSuchFieldException: findAnnotationCache at java.lang.Class.getDeclaredField(Class.java:2070) at org.springframework.boot.devtools.restart.Restarter.clear(Restarter.java:376) at org.springframework.boot.devtools.restart.Restarter.cleanupKnownCaches(Restarter.java:361) at org.springframework.boot.devtools.restart.Restarter.cleanupCaches(Restarter.java:348) at org.springframework.boot.devtools.restart.Restarter.access$000(Restarter.java:81) at org.springframework.boot.devtools.restart.Restarter$1.call(Restarter.java:170) at org.springframework.boot.devtools.restart.Restarter$1.call(Restarter.java:165) at org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:602) java.lang.NoSuchFieldException: findAnnotationCache at java.lang.Class.getDeclaredField(Class.java:2070) at org.springframework.boot.devtools.restart.Restarter.clear(Restarter.java:376) at org.springframework.boot。 devtools.restart.Restarter.cleanupKnownCaches(Restarter.java:361) 在 org.springframework.boot.devtools.restart.Restarter.cleanupCaches(Restarter.java:348) 在 org.springframework.boot.devtools.restart.Restarter.access$000 (Restarter.java:81) 在 org.springframework.boot.devtools.restart.Restarter$1.call(Restarter.java:170) 在 org.springframework.boot.devtools.restart.Restarter$1.call(Restarter.java:165) ) 在 org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:602)

Annex my code附上我的代码

package com.example.consulta;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

main.class

@SpringBootApplication
public class SpringBootSoapApp {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootSoapApp.class, args);
    }
}

Controller控制器

package com.example.consulta.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.example.consulta.entity.Cliente;
import com.example.consulta.service.ClienteService;

@RestController
public class ClienteController {

    @Autowired
    private ClienteService  clienteService;

    @GetMapping("/allCliente")
    public List<Cliente> listarCliente(){
        return clienteService.findAll();
    }

    @GetMapping("/cliente/{cedula}")
    public Cliente detalleCliente(@PathVariable int cedula) {
        return clienteService.findById(cedula);
    }


}

DAO

package com.example.consulta.DAO;

import org.springframework.data.repository.CrudRepository;

import com.example.consulta.entity.Cliente;

public interface ClienteDAO extends CrudRepository<Cliente, Integer>{
}

Entity实体

package com.example.consulta.entity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="Cliente")
public class Cliente {

    @Id
    private int cedula;
    private String nombre;
    private String apellido;
    private String tipo_cliente;

    public int getCedula() {
        return cedula;
    }
    public void setCedula(int cedula) {
        this.cedula = cedula;
    }
    public String getNombre() {
        return nombre;
    }
    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    public String getApellido() {
        return apellido;
    }
    public void setApellido(String apellido) {
        this.apellido = apellido;
    }
    public String getTipo_cliente() {
        return tipo_cliente;
    }
    public void setTipo_cliente(String tipo_cliente) {
        this.tipo_cliente = tipo_cliente;
    }   

}

Service服务

package com.example.consulta.service;

import java.util.List;

import com.example.consulta.entity.Cliente;

public interface ClienteService {

    public List<Cliente> findAll();
    public Cliente findById(int cedula);

}

ServiceImpl服务实现

package com.example.consulta.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.consulta.DAO.ClienteDAO;
import com.example.consulta.entity.Cliente;

@Service

    public class ClienteServiceImpl implements ClienteService{

        @Autowired
        private ClienteDAO clienteDao;


        @Transactional
        public List<Cliente> findAll() {
            return (List<Cliente>) clienteDao.findAll();
        }

        public Cliente findById(int cedula) {
            return clienteDao.findById(cedula).get();
        }


    }

pom.xml pom.xml

  <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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example.consulta</groupId>
  <artifactId>ServiceConsultaCliente</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>ServiceConsultaCliente</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>8</java.version>
  </properties>

  <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.2.4.RELEASE</version>
    </dependency>       
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
        <version>2.2.4.RELEASE</version>
    </dependency>
    <dependency>
         <groupId>com.oracle.jdbc</groupId>
         <artifactId>ojdbc8</artifactId>
         <version>12.2.0.1</version>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <version>1.3.0.RELEASE</version>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
          <id>codelds</id>
           <url>https://code.lds.org/nexus/content/groups/main-repo</url>
          </repository>
    </repositories>   
</project>

application.properties应用程序属性

# Oracle settings

    spring.application.name=prueba-microservicio-cliente
    server.port=8001
    spring.datasource.url=jdbc:oracle:thin:@//10.164.7.203:1521/ORCLPDB1.localdomain
    spring.datasource.username=cesar
    spring.datasource.password=xxxxx123
    spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
    spring.jpa.hibernate.ddl-auto=update

在此处输入图片说明

UPDATE After doing what specified by Marcos Barrero I get the following error: error i get:更新在执行 Marcos Barrero 指定的操作后,我收到以下错误:error i get:

pom.xml (final) 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.2.1.RELEASE</version>
    </parent>
    <groupId>com.example.consulta</groupId>
    <artifactId>ServiceConsultaCliente</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ServiceConsultaCliente</name>
    <description>Demo project for Spring Boot</description>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <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>
    </dependencies>

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

在此处输入图片说明

Try to add spring boot parent pom.尝试添加 spring boot parent pom。 With it you shouldn't specify starters versions - parent pom contains all information about needed versions.有了它,您不应该指定 starters 版本 - 父 pom 包含有关所需版本的所有信息。

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.1.RELEASE</version>
</parent>

From what I can see your problem is the way you're importing the dependencies, the recommended way to do so is by using the Spring Boot's parent pom and its managed dependencies.从我可以看出您的问题是您导入依赖项的方式,推荐的方法是使用 Spring Boot 的父 pom 及其托管依赖项。

I recommend you to use start.spring.io to generate your next projects, here's a sample with the Spring Boot dependencies that you have, the major diff is the parent pom.我建议您使用 start.spring.io 来生成您的下一个项目,这里有一个包含您拥有的 Spring Boot 依赖项的示例,主要差异是父 pom。

For your project, you need to add the extra dependencies such as oracle and any further configuration you have.对于您的项目,您需要添加额外的依赖项,例如oracle和您拥有的任何其他配置。

<?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.2.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example.consulta</groupId>
    <artifactId>ServiceConsultaCliente</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ServiceConsultaCliente</name>
    <description>Demo project for Spring Boot</description>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <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>
    </dependencies>

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

</project>

UPDATE更新

Here's your version with h2 (you have to change it to oracle)这是您的h2版本(您必须将其更改为 oracle)

<?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.2.1.RELEASE</version>
    </parent>
    <groupId>com.example.consulta</groupId>
    <artifactId>ServiceConsultaCliente</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ServiceConsultaCliente</name>
    <description>Demo project for Spring Boot</description>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- change it to oracle driver -->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <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>
    </dependencies>

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

Try use this pom.xml尝试使用这个 pom.xml

It was generated by https://start.spring.io/ and I inserted your Oracle dependencies and repositories.它是由https://start.spring.io/生成的,我插入了您的 Oracle 依赖项和存储库。

<?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.2.4.RELEASE</version>
        <relativePath/>
        <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example.consulta</groupId>
    <artifactId>ServiceConsultaCliente</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ServiceConsultaCliente</name>
    <description>Demo project for Spring Boot</description>
<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.oracle.jdbc</groupId>
        <artifactId>ojdbc8</artifactId>
        <version>12.2.0.1</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <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>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>codelds</id>
        <url>https://code.lds.org/nexus/content/groups/main-repo</url>
    </repository>
</repositories>

When you face NoSuchMethodException at runtime, it generally means 'classpath hell' - eg, for simplification, when you've got two version of the same library (one containing the method, but the other - not) and only god knows which version will actually get into your final build if you don't do anything.当你在运行时遇到 NoSuchMethodException 时,它通常意味着“类路径地狱”——例如,为了简化,当你有同一个库的两个版本(一个包含方法,但另一个不包含)并且只有上帝知道哪个版本会如果你什么都不做,实际上进入你的最终构建。

To find such dependencies, you shoult run 'mvn dependency:tree' command and search for something related to 'org.springframework.boot.devtools'... => most probably you'll see two versions要找到此类依赖项,您应该运行“mvn dependency:tree”命令并搜索与“org.springframework.boot.devtools”相关的内容... => 很可能您会看到两个版本

Then - you should either use section of maven POM to strictly set the version, or, as guys suggested above - use spring boot parent (also, a more advanced solution is importing a BOM - which is kind of a set of rules for dependency versions).然后 - 你应该使用 maven POM 的一部分来严格设置版本,或者,正如上面建议的那样 - 使用 spring boot parent(还有一个更高级的解决方案是导入一个 BOM - 这是一组依赖版本的规则)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM