У меня ошибка при установке Swagger с пружинойJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 У меня ошибка при установке Swagger с пружиной

Сообщение Anonymous »

Я пытаюсь разработать проект с весной, и я пытаюсь скачать «Swagger-Ui» для этого. Но я всегда сталкиваюсь с проблемами. Я поделюсь ошибками, которые получу с вами ниже, и я поделюсь своими файлами pom.xml, Application.properties и Application.java с вами соответственно. Я использую PostgreSQL в качестве базы данных, и я уверен, что пароль правильный.

Код: Выделить всё

    ***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
< /code>
[b] Это только одна из ошибок, которые я получаю. Когда я внесу некоторые изменения в это, ошибка может превратиться в это. [/b] 
      ***************************
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.plugin.core.support.AbstractTypeAwareSupport$BeansOfTypeTargetSource.(AbstractTypeAwareSupport.java:135)

The following method did not exist:

'void org.springframework.util.Assert.notNull(java.lang.Object)'

The calling method's class, org.springframework.plugin.core.support.AbstractTypeAwareSupport$BeansOfTypeTargetSource, was loaded from the following location:

jar:file:/C:/Users/emirg/.m2/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/support/AbstractTypeAwareSupport$BeansOfTypeTargetSource.class

The called method's class, org.springframework.util.Assert, is available from the following locations:

jar:file:/C:/Users/emirg/.m2/repository/org/springframework/spring-core/6.1.12/spring-core-6.1.12.jar!/org/springframework/util/Assert.class

The called method's class hierarchy was loaded from the following locations:

org.springframework.util.Assert: file:/C:/Users/emirg/.m2/repository/org/springframework/spring-core/6.1.12/spring-core-6.1.12.jar

Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.plugin.core.support.AbstractTypeAwareSupport$BeansOfTypeTargetSource and org.springframework.util.Assert
my pom.xml file

Код: Выделить всё

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

org.springframework.boot
spring-boot-starter-parent
3.3.3
  

kodlamaio
northwind
0.0.1-SNAPSHOT
northwind
Demo project for Spring Boot













17



org.springframework.boot
spring-boot-starter-data-jpa


org.springframework.boot
spring-boot-starter-web



org.springframework.boot
spring-boot-devtools
runtime
true


org.postgresql
postgresql
runtime


org.projectlombok
lombok
true


org.springframework.boot
spring-boot-starter-test
test


io.springfox
springfox-swagger2
2.9.2


io.springfox
springfox-swagger-ui
2.9.2





org.springframework.boot
spring-boot-maven-plugin



org.projectlombok
lombok









my Application.properties Page

Код: Выделить всё

spring.application.name=northwind
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:postgresql://localhost:5432/Northwind
spring.datasource.username=*****
spring.datasource.password=*****
spring.jpa.properties.javax.persistence.validation.mode = none
spring.datasource.driver-class-name=org.postgresql.Driver
spring.profiles.active=dev
my northwindapplication.java page

Код: Выделить всё

package kodlamaio.northwind;

import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;

import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableSwagger2
public class NorthwindApplication {

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

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("kodlamaio.northwind"))
.build();
}

}
my productscontroller.java page

Код: Выделить всё

package kodlamaio.northwind.api.controllers;

import java.util.List;

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

import kodlamaio.northwind.business.abstracts.ProductService;
import kodlamaio.northwind.entities.concretes.Product;

@RestController
@RequestMapping("/api/products")
public class ProductsController {

@Autowired
public ProductsController(ProductService productService) {
super();
this.productService = productService;
}

private ProductService productService;

@GetMapping("/getall")
public List
 getAll(){
return this.productService.getAll();

}

}
Затем я решил попробовать что-то другое и решил использовать OpenAPI-UI и добавил следующее в мой файл pom.xml.

Код: Выделить всё

org.springdoc
springdoc-openapi-ui
1.7.0

Но на этот раз я столкнулся с следующей ошибкой на Localhost: 8080 Port.
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sun Sep 01 16:06:17 TRT 2024
There was an unexpected error (type=Not Found, status=404).
No static resource swagger-ui.html.
org.springframework.web.servlet.resource.NoResourceFoundException: No static resource swagger-ui.html.
< /code>
Я знаю, что между моими пружинными папками и кодом, который я написал, существует несоответствие. Но я не знаю, как это исправить, и Chatgpt вообще не помогла.

Подробнее здесь: https://stackoverflow.com/questions/789 ... ith-spring
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Модель запросов и ответов не загружается в пользовательском интерфейсе Swagger при переходе с Swagger 1.2 на Swagger 2.0
    Anonymous » » в форуме JAVA
    0 Ответы
    58 Просмотры
    Последнее сообщение Anonymous
  • Иметь строчное значение от поля Enum при отправке запроса с пружиной
    Anonymous » » в форуме JAVA
    0 Ответы
    21 Просмотры
    Последнее сообщение Anonymous
  • Иметь строчное значение от поля Enum при отправке запроса с пружиной
    Anonymous » » в форуме JAVA
    0 Ответы
    13 Просмотры
    Последнее сообщение Anonymous
  • Проблема транзакции при смешивании JDBC/JPA с пружиной
    Anonymous » » в форуме JAVA
    0 Ответы
    3 Просмотры
    Последнее сообщение Anonymous
  • Mybatis с пружиной: не удалось найти карту результатов
    Anonymous » » в форуме JAVA
    0 Ответы
    15 Просмотры
    Последнее сообщение Anonymous

Вернуться в «JAVA»