我运行后的应用程序正常运行没有错误,但在我尝试使用Postman它出现错误:连接EAMPLIFUSED 127.0.0.1:8080.在我的applicationProperties服务器端口设置为8080,XAMPP已打开,但仍然是一个错误.我已经尝试删除Postman和XAMPP并重新安装它们,但我仍然得到相同的错误.
POST http://localhost:8080/api/product-categories
Error: connect ECONNREFUSED 127.0.0.1:8080
Request Headers
Content-Type: application/json
User-Agent: PostmanRuntime/7.36.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 28c3391d-ae3f-4031-aa24-d43ecd2e2bf4
Host: localhost:8080
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Request Body
x
server.port=8080
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/kadaiden
spring.datasource.username=root
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.santiang:demo-kadaiden >---------------------
[INFO] Building demo-kadaiden 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:3.2.1:run (default-cli) > test-compile @ demo-kadaiden >>>
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ demo-kadaiden ---
[INFO] Copying 1 resource from src\main\resources to target\classes
[INFO] Copying 0 resource from src\main\resources to target\classes
[INFO]
[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ demo-kadaiden ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:testResources (default-testResources) @ demo-kadaiden ---
[INFO] skip non existing resourceDirectory D:\Air\Latihan Spring Boot\demo-kadaiden\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.11.0:testCompile (default-testCompile) @ demo-kadaiden ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:3.2.1:run (default-cli) < test-compile @ demo-kadaiden <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:3.2.1:run (default-cli) @ demo-kadaiden ---
[INFO] Attaching agents: []
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.1)
2023-12-31T14:02:42.030+07:00 INFO 9648 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http)
2023-12-31T14:02:42.043+07:00 INFO 9648 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-12-31T14:02:42.043+07:00 INFO 9648 --- [ restartedMain] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.17]
2023-12-31T14:02:42.103+07:00 INFO 9648 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-12-31T14:02:42.105+07:00 INFO 9648 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1423 ms
2023-12-31T14:02:42.244+07:00 INFO 9648 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-12-31T14:02:42.306+07:00 INFO 9648 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.4.1.Final
2023-12-31T14:02:43.859+07:00 WARN 9648 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling
refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productCategoryMasterController' defined in file [D:\Air\
Latihan Spring Boot\demo-kadaiden\target\classes\com\santiang\demokadaiden\controller\ProductCategoryMasterController.class]: Unsatisfied dependency expressed through cons
tructor parameter 0: Error creating bean with name 'productCategoryMasterImpl' defined in file [D:\Air\Latihan Spring Boot\demo-kadaiden\target\classes\com\santiang\demoka
daiden\service\impl\ProductCategoryMasterImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'productCategoryRepos
itory' defined in com.santiang.demokadaiden.repository.ProductCategoryRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositori
esConfiguration: Could not create query for public abstract java.util.List com.santiang.demokadaiden.repository.ProductCategoryRepository.findAllByOrderName(); Reason: Fai
led to create query for method public abstract java.util.List com.santiang.demokadaiden.repository.ProductCategoryRepository.findAllByOrderName(); No property 'orderName'
found for type 'ProductCategory'
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-12-31T14:02:43.906+07:00 ERROR 9648 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productCategoryMasterController' defined in file [D:\Air\Latihan Spring Bo
ot\demo-kadaiden\target\classes\com\santiang\demokadaiden\controller\ProductCategoryMasterController.class]: Unsatisfied dependency expressed through constructor parameter
0: Error creating bean with name 'productCategoryMasterImpl' defined in file [D:\Air\Latihan Spring Boot\demo-kadaiden\target\classes\com\santiang\demokadaiden\service\im
pl\ProductCategoryMasterImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'productCategoryRepository' defined in
com.santiang.demokadaiden.repository.ProductCategoryRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration:
Could not create query for public abstract java.util.List com.santiang.demokadaiden.repository.ProductCategoryRepository.findAllByOrderName(); Reason: Failed to create que
ry for method public abstract java.util.List com.santiang.demokadaiden.repository.ProductCategoryRepository.findAllByOrderName(); No property 'orderName' found for type 'P
roductCategory'
at ~[spring-boot-devtools-3.2.1.jar:3.2.1]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productCategoryMasterImpl' defined in file [D:\Air\Latihan Spri
ng Boot\demo-kadaiden\target\classes\com\santiang\demokadaiden\service\impl\ProductCategoryMasterImpl.class]: Unsatisfied dependency expressed through constructor paramete
r 0: Error creating bean with name 'productCategoryRepository' defined in com.santiang.demokadaiden.repository.ProductCategoryRepository defined in @EnableJpaRepositories
declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract java.util.List com.santiang.demokadaiden.repository.Pro
ductCategoryRepository.findAllByOrderName(); Reason: Failed to create query for method public abstract java.util.List com.santiang.demokadaiden.repository.ProductCategoryR
epository.findAllByOrderName(); No property 'orderName' found for type 'ProductCategory'
at
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.666 s
[INFO] Finished at: 2023-12-31T14:02:44+07:00
[INFO] ------------------------------------------------------------------------
PS D:\Air\Latihan Spring Boot\demo-kadaiden> mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.santiang:demo-kadaiden >---------------------
[INFO] Building demo-kadaiden 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:3.2.1:run (default-cli) > test-compile @ demo-kadaiden >>>
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ demo-kadaiden ---
[INFO] Copying 1 resource from src\main\resources to target\classes
[INFO] Copying 0 resource from src\main\resources to target\classes
[INFO]
[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ demo-kadaiden ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:testResources (default-testResources) @ demo-kadaiden ---
[INFO] skip non existing resourceDirectory D:\Air\Latihan Spring Boot\demo-kadaiden\src\test\resources
@Entity
@Table(name = "product_category")
@Getter
@Setter
@NoArgsConstructor
@ToString
public class ProductCategory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
private String name;
public ProductCategory(Long id, String name) {
this.id = id;
this.name = name;
}
}
的数据
1条答案
按热度按时间sqserrrh1#
(当前)阻止Sping Boot 启动的错误是:
创建在com.santiang.demokadaiden.repository中定义的名为“productCategoryRepository”的Bean时出错。在JpaRepositoriesRegistrar上声明的@ EnableJpaRepositories中定义的ProductCategoryRepository。EnableJpaRepositoriesConfiguration:无法为公共抽象java.util.List com.santiang.demokadaiden.repository.ProductCategoryRepository.findAllByOrderName()创建查询;原因:无法为方法public abstract java.util.List com.santiang.demokadaiden.repository.ProductCategoryRepository.findAllByOrderName()创建查询;未找到类型“ProductCategory”的属性“orderName”
问题是
ProductCategoryRepository
有一个名为findAllByOrderName()
的方法,但ProductCategory
没有一个名为orderName
的属性。它确实有一个属性name
,这可能是你需要使用的。所以,为了解决这个问题,将ProductCategoryRepository
中的方法定义为findAllByName()
。