緣由是把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