我不明白为什么会出现这个问题,因为我已经编写了@EnableJpaRepository
AppStarter
package com.servers;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@SpringBootApplication
@EntityScan
@EnableJpaRepositories(basePackageClasses=com.servers.server1.dao.LinieDao.class)
@EnableAutoConfiguration
public class ServersApplication {
public static void main(String[] args) {
SpringApplication.run(ServersApplication.class, args);
}
}
App proprieties
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.database.driverClassName=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.url=jdbc:postgresql://localhost:5432/ServersDataBase
spring.datasource.username=postgre
spring.datasource.password=22ALGORITMul!(($
的Controler
package com.servers.server1.controler;
import com.servers.server1.models.Linie;
import com.servers.server1.service.LinieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Random;
/**
* Created by OGKey on 07-Jan-18.
*/
@RestController
public class LinieControler {
@Autowired
private LinieService linieService;
@RequestMapping(value="/show_linii")
@CrossOrigin
public List<Linie> getAll(){
return linieService.getAll();
}
@RequestMapping(value="/linia")
@CrossOrigin
public String getByNr(@RequestParam("id") String nr){
return linieService.getLinieByNr(nr).toString();
}
@RequestMapping(value="/adauga")
@CrossOrigin
public void addLinie(){
Random r= new Random();
linieService.addLinie(String.valueOf(r.nextInt(10)),r.nextInt(20));
}
}
存储库
package com.servers.server1.dao;
import com.servers.server1.models.Linie;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface LinieDao extends CrudRepository<Linie,Long>{
public Linie findByNr(String nr);
}
模型
package com.servers.server1.models;
import javax.persistence.*;
@Entity
@Table
public class Linie {
@Column(name="Nr")
private String numar;
@Column(name="Plecare1")
private int[] plecare1;
@Column(name="Plecare2")
private int[] plecare2;
@Column(name="Delay")
private int delay;
public Linie(){
plecare1= new int[12];
plecare2= new int[12];
}
public Linie(String numar){
this();
this.numar=numar;
defaultIt();
}
public Linie(int delay){
this();
this.delay=delay;
defaultIt();
}
public Linie(String numar, int delay){
this();
this.numar=numar;
this.delay=delay;
defaultIt();
}
public void defaultIt(){
for(int i=0; i<12; i++){
plecare1[i]=i;
plecare2[i]=i+2;
}
}
public String getNumar() {
return numar;
}
public void setNumar(String numar) {
this.numar = numar;
}
public int[] getPlecare1() {
return plecare1;
}
public void setPlecare1(int[] plecare1) {
this.plecare1 = plecare1;
}
public int[] getPlecare2() {
return plecare2;
}
public void setPlecare2(int[] plecare2) {
this.plecare2 = plecare2;
}
public int getDelay() {
return delay;
}
public void setDelay(int delay) {
this.delay = delay;
}
public String toString(){
String show;
show="Linia "+numar+" are "+delay+" intarziere.";
return show;
}
}
服务
package com.servers.server1.service;
import com.servers.server1.dao.LinieDao;
import com.servers.server1.models.Linie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class LinieService {
@Autowired
LinieDao db;
public Linie getLinieByNr(String nr){
return db.findByNr(nr);
}
public List<Linie> getAll(){
List<Linie> linii= new ArrayList<Linie>();
for(Linie linie: db.findAll()){
linii.add(linie);
}
return linii;
}
public void updateDelay(String nr, int delay){
for(Linie linie: db.findAll()){
if(linie.getNumar().equals(nr)){
linie.setDelay(delay);
db.save(linie);
}
}
}
public void addLinie(String nr, int delay){
try{
db.save(new Linie(nr, delay));
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public void removeLinie(String nr){
db.delete(db.findByNr(nr));
}
}
的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>servers</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Servers</name>
<description>Comunicating Servers</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
<version>3.1.11</version>
</dependency>
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-starter</artifactId>
<version>2.0.0.M2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.13.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
日志
"C:\Program Files\Java\jdk1.8.0_111\bin\java" -Dspring.output.ansi.enabled=always -Didea.launcher.port=7541 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_111\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_111\jre\lib\rt.jar;H:\Faculta\An 4\Sem 1\IOM\Servers\target\classes;C:\Users\OGKey\.m2\repository\org\apache\cxf\cxf-spring-boot-starter-jaxrs\3.1.11\cxf-spring-boot-starter-jaxrs-3.1.11.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter\1.5.9.RELEASE\spring-boot-starter-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot\1.5.9.RELEASE\spring-boot-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.9.RELEASE\spring-boot-autoconfigure-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter-logging\1.5.9.RELEASE\spring-boot-starter-logging-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;C:\Users\OGKey\.m2\repository\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;C:\Users\OGKey\.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\OGKey\.m2\repository\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;C:\Users\OGKey\.m2\repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;C:\Users\OGKey\.m2\repository\org\apache\cxf\cxf-spring-boot-autoconfigure\3.1.11\cxf-spring-boot-autoconfigure-3.1.11.jar;C:\Users\OGKey\.m2\repository\org\apache\cxf\cxf-rt-transports-http\3.1.11\cxf-rt-transports-http-3.1.11.jar;C:\Users\OGKey\.m2\repository\org\apache\cxf\cxf-core\3.1.11\cxf-core-3.1.11.jar;C:\Users\OGKey\.m2\repository\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;C:\Users\OGKey\.m2\repository\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;C:\Users\OGKey\.m2\repository\org\apache\ws\xmlschema\xmlschema-core\2.2.1\xmlschema-core-2.2.1.jar;C:\Users\OGKey\.m2\repository\org\apache\cxf\cxf-rt-frontend-jaxrs\3.1.11\cxf-rt-frontend-jaxrs-3.1.11.jar;C:\Users\OGKey\.m2\repository\javax\ws\rs\javax.ws.rs-api\2.0.1\javax.ws.rs-api-2.0.1.jar;C:\Users\OGKey\.m2\repository\javax\annotation\javax.annotation-api\1.2\javax.annotation-api-1.2.jar;C:\Users\OGKey\.m2\repository\org\apache\cxf\cxf-rt-rs-client\3.1.11\cxf-rt-rs-client-3.1.11.jar;C:\Users\OGKey\.m2\repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;C:\Users\OGKey\.m2\repository\org\springframework\shell\spring-shell-starter\2.0.0.M2\spring-shell-starter-2.0.0.M2.jar;C:\Users\OGKey\.m2\repository\org\springframework\shell\spring-shell-core\2.0.0.M2\spring-shell-core-2.0.0.M2.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter-validation\1.5.9.RELEASE\spring-boot-starter-validation-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\jline\jline\3.4.0\jline-3.4.0.jar;C:\Users\OGKey\.m2\repository\org\jline\jline-terminal-jna\3.4.0\jline-terminal-jna-3.4.0.jar;C:\Users\OGKey\.m2\repository\net\java\dev\jna\jna\4.2.2\jna-4.2.2.jar;C:\Users\OGKey\.m2\repository\org\jline\jline-terminal\3.4.0\jline-terminal-3.4.0.jar;C:\Users\OGKey\.m2\repository\org\springframework\shell\spring-shell-standard\2.0.0.M2\spring-shell-standard-2.0.0.M2.jar;C:\Users\OGKey\.m2\repository\org\springframework\shell\spring-shell-standard-commands\2.0.0.M2\spring-shell-standard-commands-2.0.0.M2.jar;C:\Users\OGKey\.m2\repository\org\springframework\shell\spring-shell-shell1-adapter\2.0.0.M2\spring-shell-shell1-adapter-2.0.0.M2.jar;C:\Users\OGKey\.m2\repository\org\springframework\shell\spring-shell-jcommander-adapter\2.0.0.M2\spring-shell-jcommander-adapter-2.0.0.M2.jar;C:\Users\OGKey\.m2\repository\org\springframework\shell\spring-shell-table\2.0.0.M2\spring-shell-table-2.0.0.M2.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter-thymeleaf\1.5.9.RELEASE\spring-boot-starter-thymeleaf-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\thymeleaf\thymeleaf-spring4\2.1.6.RELEASE\thymeleaf-spring4-2.1.6.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\thymeleaf\thymeleaf\2.1.6.RELEASE\thymeleaf-2.1.6.RELEASE.jar;C:\Users\OGKey\.m2\repository\ognl\ognl\3.0.8\ognl-3.0.8.jar;C:\Users\OGKey\.m2\repository\org\unbescape\unbescape\1.1.0.RELEASE\unbescape-1.1.0.RELEASE.jar;C:\Users\OGKey\.m2\repository\nz\net\ultraq\thymeleaf\thymeleaf-layout-dialect\1.4.0\thymeleaf-layout-dialect-1.4.0.jar;C:\Users\OGKey\.m2\repository\org\codehaus\groovy\groovy\2.4.13\groovy-2.4.13.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter-web\1.5.9.RELEASE\spring-boot-starter-web-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\hibernate\hibernate-validator\5.3.6.Final\hibernate-validator-5.3.6.Final.jar;C:\Users\OGKey\.m2\repository\org\jboss\logging\jboss-logging\3.3.1.Final\jboss-logging-3.3.1.Final.jar;C:\Users\OGKey\.m2\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;C:\Users\OGKey\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.10\jackson-databind-2.8.10.jar;C:\Users\OGKey\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;C:\Users\OGKey\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.10\jackson-core-2.8.10.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-web\4.3.13.RELEASE\spring-web-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-aop\4.3.13.RELEASE\spring-aop-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-context\4.3.13.RELEASE\spring-context-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-webmvc\4.3.13.RELEASE\spring-webmvc-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-expression\4.3.13.RELEASE\spring-expression-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\postgresql\postgresql\9.4.1212.jre7\postgresql-9.4.1212.jre7.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-core\4.3.13.RELEASE\spring-core-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.23\tomcat-embed-el-8.5.23.jar;C:\Users\OGKey\.m2\repository\org\springframework\data\spring-data-commons\1.13.6.RELEASE\spring-data-commons-1.13.6.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-beans\4.3.13.RELEASE\spring-beans-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\OGKey\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.0.0.M7\spring-boot-starter-data-jpa-2.0.0.M7.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter-aop\1.5.9.RELEASE\spring-boot-starter-aop-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;C:\Users\OGKey\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\1.5.9.RELEASE\spring-boot-starter-jdbc-1.5.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\apache\tomcat\tomcat-jdbc\8.5.23\tomcat-jdbc-8.5.23.jar;C:\Users\OGKey\.m2\repository\org\apache\tomcat\tomcat-juli\8.5.23\tomcat-juli-8.5.23.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-jdbc\4.3.13.RELEASE\spring-jdbc-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\hibernate\hibernate-core\5.0.12.Final\hibernate-core-5.0.12.Final.jar;C:\Users\OGKey\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar;C:\Users\OGKey\.m2\repository\org\javassist\javassist\3.21.0-GA\javassist-3.21.0-GA.jar;C:\Users\OGKey\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\OGKey\.m2\repository\org\apache\geronimo\specs\geronimo-jta_1.1_spec\1.1.1\geronimo-jta_1.1_spec-1.1.1.jar;C:\Users\OGKey\.m2\repository\org\jboss\jandex\2.0.0.Final\jandex-2.0.0.Final.jar;C:\Users\OGKey\.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\OGKey\.m2\repository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;C:\Users\OGKey\.m2\repository\org\springframework\data\spring-data-jpa\1.11.9.RELEASE\spring-data-jpa-1.11.9.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-orm\4.3.13.RELEASE\spring-orm-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-tx\4.3.13.RELEASE\spring-tx-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\org\springframework\spring-aspects\4.3.13.RELEASE\spring-aspects-4.3.13.RELEASE.jar;C:\Users\OGKey\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Users\OGKey\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.2\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.servers.ServersApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.9.RELEASE)
2018-01-07 16:46:41.648 INFO 13752 --- [ main] com.servers.ServersApplication : Starting ServersApplication on DESKTOP-LG7Q1UV with PID 13752 (started by OGKey in H:\Faculta\An 4\Sem 1\IOM\Servers)
2018-01-07 16:46:41.651 INFO 13752 --- [ main] com.servers.ServersApplication : No active profile set, falling back to default profiles: default
2018-01-07 16:46:42.058 INFO 13752 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7d68ef40: startup date [Sun Jan 07 16:46:42 EET 2018]; root of context hierarchy
2018-01-07 16:46:43.178 INFO 13752 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.shell.SpringShellAutoConfiguration' of type [org.springframework.shell.SpringShellAutoConfiguration$$EnhancerBySpringCGLIB$$90afdbd8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-07 16:46:43.201 INFO 13752 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'conversionService' of type [org.springframework.core.convert.support.DefaultConversionService] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-07 16:46:43.385 WARN 13752 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'linieControler': Unsatisfied dependency expressed through field 'linieService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'linieService': Unsatisfied dependency expressed through field 'db'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'linieDao': Cannot create inner bean '(inner bean)#433ffad1' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#433ffad1': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
2018-01-07 16:46:43.397 INFO 13752 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-01-07 16:46:43.472 ERROR 13752 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field db in com.servers.server1.service.LinieService required a bean named 'entityManagerFactory' that could not be found.
Action:
Consider defining a bean named 'entityManagerFactory' in your configuration.
Process finished with exit code 1
我已经阅读了整个stackoverflow.Did没有设法创建一个bean既没有找到appConfig.xml文件,依赖就在那里,并且尝试了不同的方法来自@EnableJpaRepository
请帮忙。
答案 0 :(得分:0)
你已经在pom中定义了spring-boot-starter-data-jpa依赖两次。也许本地回购破坏了hibernate-entity- * jar。删除maven local repo并重试。
答案 1 :(得分:0)
在ServersApplication
课程中,还会移除@EnableAutoConfiguration
注释。
它已包含在@SpringBootApplication
中
您可以在documentation
@SpringBootApplication注释等同于使用 @Configuration,@ EnableAutoConfiguration和@ComponentScan与他们的 默认属性
更进一步,您可以非常轻松地检查使用哪些依赖项创建的bean。有两种方法。通过使用ListableBeanFactory
接口或弹簧启动执行器。检查this tutorial如何执行此操作。如果您使用执行器解决方案,您还可以查看endpoints的文档以获取更多信息
答案 2 :(得分:0)
好吧,我找到了为什么我的应用程序无法运行的原因。 entityManagerFactory与声明的数据库表中的@Id
基列一起使用。我不需要,所以我没有使用它,但在添加它之后它工作了