下午好,我正在尝试生成一个与Java spring boot的Rest服务,但当尝试执行jar时,我得到以下错误,这让我头疼,我不知道具体是什么:
java.lang.nosuchmethoderror:org.springframework.data.repository.configurationrepositoryconfigurationsource.(log/springframework/core/type/annotationmetadata;ljava/lang/class;log/springframework/core/io/resourceloader;log/springframework/core/env/environment;)V在ROMRegistrars$1(ConfigurationClassBeanDefinitionReader.java:385)位于java.util.LinkedHashMap.foreach(LinkedHashMap.java:684)位于org.SpringFramework.Context.Annotation.ConfigurationClassBeanDefinitionReader.LoadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.384)位于PostProcessorRegistrationDelegate.java:275)位于org.springframework.context.support.PostProcessorRegistrationDelegate.InvokeBeanFactoryPostProcessor(PostProcessorRegistrationDelegate.java:95)位于org.springframework.context.support.abstractapplicationcontext.InvokeBeanFactoryPostProcessor(PostProcessorRegistrationDelegate.java:706)位于ta.springbootsoapapp.main(springbootsoapapp.java:12)位于sun.reflect.nativeMethodAccessorImpl.Invoke0(原生方法)位于sun.reflect.nativeMethodAccessorImpl.java:62)sun.reflect.delegatingmethodAccessorImpl.Invoke(原生方法)位于sun.reflect.delegatingmethodAccessorImpl.java:43)java.lang.reflect.Method.Invoke(原生方法)位于
java.lang.nosuchfieldexception:findAnnotationCache在java.lang.class.getdeclaredfield(class.java:2070)在org.springframework.boot.devtools.restart.restarter.clear(restarter.java:376)在org.springframework.boot.devtools.restart.cleanupknowncaches(restarter.java:361)在org.springframework.boot.devtools.restart.cleanupcaches(
附件MI代码
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);
}
}
控制器
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);
}
}
刀
package com.example.consulta.DAO;
import org.springframework.data.repository.CrudRepository;
import com.example.consulta.entity.Cliente;
public interface ClienteDAO extends CrudRepository<Cliente, Integer>{
}
实体
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;
}
}
服务
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
<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>
应用程序.属性
# 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
更新完成Marcos Barrero指定的操作后,我得到以下错误:
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>
尝试添加spring boot父级POM。使用它,您不应该指定starters版本-父pom包含关于所需版本的所有信息。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
</parent>
从我所看到的问题是导入依赖项的方式,推荐的方法是使用spring boot的父pom及其托管依赖项。
我建议您使用start.Spring.io来生成您的下一个项目,这里有一个示例,其中包含了您所拥有的spring boot依赖项,主要区别是父POM。
对于您的项目,您需要添加额外的依赖项,如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>
更新
这是您的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>
我的android构建在构建后失败,这是我得到的错误日志总时间:1分钟,16.631秒停止0编译器守护进程。接收到的结果失败[value=org.gradle.initialization.ReportedException:org.gradle.internal.Exceptions.LocationAwareException:任务“:DexRelease”的执行失败。]from Daemon
问题内容: 我收到一个错误,指示缺少in 。这是我的网络服务代码: 这是我的: 添加应用程序类无效: 我仍然收到此错误: UPDATE2: 现在我从浏览器执行GET请求时收到此错误 问题答案: 用(或其他字符串)注释您的班级。
我有一个SpringBoot应用程序,它有一个控制器类、一个服务和一个存储库,运行得非常好。我已经为相同的应用程序添加了Junit测试用例,而且效果也非常好。 下面是测试类。 测试用例一直通过,但目前我正在添加另一个API,如下所示,所有测试都失败了。 下面是测试类。 添加部门服务后,测试用例失败,错误如下: 干杯!
[ERROR]未能在项目上执行goal org.jooq:jooq-codegen-maven:3.15.1:generate(默认)事件-dao-jooq:goal org.jooq:jooq-codegen-maven:3.15.1:generate失败:由于API不兼容,无法加载插件'org.jooq:jooq-codegen-maven:3.15.1'中的mojo“generate”:or
问题内容: 我已经设置了一个Jenkins服务器来运行Selenium测试。生成脚本是用Ant(CentOS 6.3上的v 1.7.1)编写的,并且测试在Sauce Labs上运行。我通过外壳执行构建: 问题是测试失败时,詹金斯(Jenkins)将其标记为成功。我可以通过将设置为来避免这种情况,请参阅: 但是,这并不理想,因为Jenkins会在遇到第一个故障时终止构建。构建完成后是否可以检查失败,
我已经设置了一个Jenkins服务器来运行Selenium测试。构建脚本是用Ant(CentOS 6.3上的V1.7.1)编写的,测试在Sauce实验室上运行。我通过shell执行构建: