我使用spring启动程序创建了一个项目,但它不会运行。它会给我一条如下所示的错误消息:
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$AutoConfiguredAnnotationRepositoryConfigurationSource.<init>(AbstractRepositoryConfigurationSourceSupport.java:133)
The following method did not exist:
org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;Lorg/springframework/beans/factory/support/BeanNameGenerator;)V
The method's class, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource, is available from the following locations:
jar:file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar!/org/springframework/data/repository/config/AnnotationRepositoryConfigurationSource.class
The class hierarchy was loaded from the following locations:
org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource: file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar
org.springframework.data.repository.config.RepositoryConfigurationSourceSupport: file:/Users/miguelmunoz/.m2/repository/org/springframework/data/spring-data-commons/1.13.10.RELEASE/spring-data-commons-1.13.10.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource
我不知道怎么解决这个问题。我已经在https://github.com/swingguy1024/dummy.artifact-mrtc上签入了一个最小可复制的测试用例
我的pom文件是这样的:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>dummy</groupId>
<artifactId>dummy.artifact</artifactId>
<packaging>jar</packaging>
<name>dummy.artifact</name>
<version>1.0</version>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<springfox-version>2.9.2</springfox-version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<!--<version>2.3.3.RELEASE</version>--> <!--I tried both. Neither version worked.-->
</parent>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--SpringFox dependencies -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<!--Handles serialization/deserialization of new Java Date/Time classes-->
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Neumann-SR4</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>
补遗:据我所知,我只有AnnotationRepositoryConfigurationSource的单一版本,它在spring-Data-Commons存储库中。按照我的理解,spring数据的版本应该由我的pom.xml文件的dependencyManagement部分确定,我在这里指定了spring数据发布表。我试过几种不同的值,但都不起作用。这里指定的neumann-sr4
是最新的一个。但它并没有给我提供最新版本的spring数据公域。
增编2:gtiwari333建议的修改如下
我做了以下更改,并将它们签入GitHub存储库。我还有一个问题。
dummy.entity
包中创建了一个新的CTwo类。javax.servlet.http.HttpServletRequest
)Jackson-Datatype-JSR310
、Validation-API
和jackson-Annotations
(这些更改使我想到了导致我创建此MRTC的最初bug。)
我仍然会收到一条错误消息,尽管是不同的。
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(AnnotationRepositoryConfigurationSource.java:126)
The following method did not exist:
org.springframework.core.type.AnnotationMetadata.introspect(Ljava/lang/Class;)Lorg/springframework/core/type/AnnotationMetadata;
The method's class, org.springframework.core.type.AnnotationMetadata, is available from the following locations:
jar:file:/Users/miguelmunoz/.m2/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar!/org/springframework/core/type/AnnotationMetadata.class
It was loaded from the following location:
file:/Users/miguelmunoz/.m2/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.core.type.AnnotationMetadata
再一次,我只有这个类的一个版本。
我看到你的代码有几个问题。其中一个或所有这些都可能导致你面临的问题。
dummy.invoker.swagger2SpringBoot
中没有dummy
。spring boot建议您将@SpringBootApplication类放在根包中,这样它就可以扫描所有的组件和存储库,而无需您手动扫描。如果必须将该类放在dummy.invoker
包中,那么请执行以下操作,以便它扫描存储库类@enableJParepositories(basePackages={“dummy.Repository”})
还有,
@EntityScan(basePackages={“dummy.model”})
扫描CTwo实体
参见:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-locating-the-main-class
@Entity
public class CTwo {
@JsonProperty("id")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id = null;
额外备注:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Neumann-SR4</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
@Repository
@Component
public interface CTwoRepository ...
在运行应用程序之前,请参阅此修补程序,了解所需进行的更改:
还有,为什么用的是老spring boot版?请将其更新为最新版本。
Index: src/main/java/dummy/repository/CTwoRepository.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/dummy/repository/CTwoRepository.java (revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ src/main/java/dummy/repository/CTwoRepository.java (date 1601681768001)
@@ -12,7 +12,5 @@
*
* @author Miguel Mu\u00f1oz
*/
-@Repository
-@Component
public interface CTwoRepository extends JpaRepository<CTwo, Integer> {
}
Index: src/main/java/dummy/model/CTwo.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/dummy/model/CTwo.java (revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ src/main/java/dummy/model/CTwo.java (date 1601681492814)
@@ -7,18 +7,22 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;
+
+import javax.persistence.*;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* CTwo
*/
-@Validated
-@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-01T10:23:27.051Z[GMT]")
+//@Validated
+//@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-01T10:23:27.051Z[GMT]")
@JsonInclude(JsonInclude.Include.NON_NULL)
-
+@Entity
public class CTwo {
@JsonProperty("id")
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id = null;
@JsonProperty("name")
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- pom.xml (revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ pom.xml (date 1601682065794)
@@ -15,8 +15,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
- <version>2.1.7.RELEASE</version>
- <!--<version>2.3.3.RELEASE</version>--> <!--I tried both. Neither version worked.-->
+ <version>2.3.4.RELEASE</version>
</parent>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
@@ -74,55 +73,5 @@
<version>${springfox-version}</version>
</dependency>
- <!--<dependency>-->
- <!-- <groupId>jakarta.xml.bind</groupId>-->
- <!-- <artifactId>jakarta.xml.bind-api</artifactId>-->
- <!-- <version>2.3.2</version>-->
- <!--</dependency>-->
-
- <!--<!– Runtime, com.sun.xml.bind module –>-->
- <!--<dependency>-->
- <!-- <groupId>org.glassfish.jaxb</groupId>-->
- <!-- <artifactId>jaxb-runtime</artifactId>-->
- <!-- <version>2.3.2</version>-->
- <!--</dependency>-->
-
- <dependency>
- <!--Handles serialization/deserialization of new Java Date/Time classes-->
- <groupId>com.fasterxml.jackson.datatype</groupId>
- <artifactId>jackson-datatype-jsr310</artifactId>
- </dependency>
- <!-- Bean Validation API support -->
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- <version>2.10.1</version>
- </dependency>
-
- <!--<!–Actuator–>-->
- <!--<dependency>-->
- <!-- <groupId>org.springframework.boot</groupId>-->
- <!-- <artifactId>spring-boot-actuator-docs</artifactId>-->
- <!-- <version>1.5.10.RELEASE</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!-- <groupId>org.springframework.boot</groupId>-->
- <!-- <artifactId>spring-boot-starter-actuator</artifactId>-->
- <!--</dependency>-->
</dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-releasetrain</artifactId>
- <version>Neumann-SR4</version>
- <scope>import</scope>
- <type>pom</type>
- </dependency>
- </dependencies>
- </dependencyManagement>
</project>
Index: src/main/java/dummy/invoker/Swagger2SpringBoot.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/java/dummy/invoker/Swagger2SpringBoot.java (revision 27a2e1045263f79fd3c490fce14b2640b12fa3a4)
+++ src/main/java/dummy/invoker/Swagger2SpringBoot.java (date 1601681394614)
@@ -4,13 +4,17 @@
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableSwagger2
-@ComponentScan(basePackages = { "dummy.invoker", "dummy.api" , "dummy.config", "dummy.repository"})
+@EnableJpaRepositories(basePackages = {"dummy.repository"})
+@EntityScan(basePackages = {"dummy.model"})
+@ComponentScan(basePackages = { "dummy.invoker", "dummy.api" , "dummy.config" })
public class Swagger2SpringBoot implements CommandLineRunner {
@Override
问题内容: 我是Web入门的新手,我们使用exe4j从One-jar创建可执行文件。为了制作我们应用程序的“网络启动版本”,我尝试使用具有指定Main- Class的网络启动功能对One-JAR进行午餐,但是出现以下错误- JNLP包含- 我正在尝试直接启动 Application.jar ,而 com.simontuffs.onejar.Boot 是为JAR指定的主要类。我还发现此链接表明我们无
logcat给我这个错误: 当我将应用程序从eclipse部署到emulator时,它工作正常。当我关闭应用程序并尝试再次运行时,出现问题,然后我收到消息: 这是我的舱单。xml 有人能检查一下出了什么问题吗? 谢谢
我在raspberry pi 3(raspbian)上使用一个MariaDB,我有一个具有特定密码的root用户 问题:当我重新启动raspberry时,用户的访问被拒绝root@localhost 我确实用mysqld重置了根密码——跳过授权表,并刷新了权限。然后我重新启动了服务器。 之后,当我输入sudo mysql时,我无需询问密码即可登录。 当我再次重新启动覆盆子时,用户的访问被拒绝roo
在Payara 5.194上运行Java EE 8 web应用程序。自从我启动Payara及其应用程序以来,已经有一段时间了。 当我启动服务器时:我收到6个过期证书的消息。 之后我得到了这个异常 没有代码被改变,什么都没有。Payara就是不会启动。
从今天起,我们的Airflow服务无法访问BigQuery中的查询。所有作业都会失败,并显示以下消息: [2021-03-12 10:17:28079]{taskinstance.py:1150}错误-原因:403获取https://bigquery.googleapis.com/bigquery/v2/projects/waipu-app-prod/queries/e62030d7-36eb-4
在VM上,当试图使用ChromeDriver和WebDriverManager启动Chrome浏览器时,在LaunchChromeDriver方法测试失败,在步骤new ChromeDriver(选项)中失败为“访问被拒绝”; 该方法如下所示: 我是遗漏了什么还是需要修改代码?有人经历过同样的事情吗? 获取如下所示的异常: System.ComponentModel.Win32Exception(