缘由是把Application.java放在了以下所示:java
解决: 把Application.java放到最外层便可解决web
缘由: 包的问题。 解决方案, 修改pom文件spring
<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.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
Caused by: java.lang.NoClassDefFoundError: org/springframework/security/config/http/SessionCreationPolicy at org.springframework.boot.actuate.autoconfigure.ManagementServerProperties$Security.<init>(ManagementServerProperties.java:186) ~[spring-boot-actuator-1.4.0.RELEASE.jar:1.4.0.RELEASE] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_162] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_162] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_162] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_162] at java.lang.Class.newInstance(Class.java:442) ~[na:1.8.0_162] at org.springframework.beans.BeanUtils.instantiate(BeanUtils.java:77) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.beans.AbstractNestablePropertyAccessor.newValue(AbstractNestablePropertyAccessor.java:914) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE] ... 125 common frames omitted
报错信息如图所示: 出错缘由: 由于没有找到该类。因此就出现这个问题,由于咱们在配置消息总线时加入了该配置:management.security.enable=false,该配置须要对Spring的security包产生依赖。但在项目pom中并无去依赖Spring的security包。安全
解决方案: 在pom文件中增长对security包的依赖:app
<!-- 对Spring security安全包的依赖,不然会报错 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
DiscoveryClient_SPRINGCLOUD-QUERYDSL/10.0.2.140:springcloud-querydsl:4445 - was unable to refresh its cache! status = Cannot execute request on any known server
缘由: 没有启动注册中心,致使服务没法进行注册,因此会报Cannot execute request on any known server 解决方案: 启动注册中心maven
org.hibernate.MappingException: Could not determine type for: java.util.List, at table: teacher, for columns: [org.hibernate.mapping.Column(students)]
缘由: 由于Teacher与Student是一对多关系,在Teacher里面有List<Student>这么一个引用,因此须要指定它们之间的关系、好比@OneToMany、@ManyToOne等。 解决方案: 指定相应的关系便可。spring-boot