为了账号安全,请及时绑定邮箱和手机立即绑定

请问老师,我的创建了GirlProperties之后,java项目就启动不起来了

2017-08-17 10:27:17.207  INFO 7438 --- [           main] com.example.demo.GirlApplication         : Starting GirlApplication on lfhbgs with PID 7438 (/home/cgc/Documents/workspace-sts-3.8.3.RELEASE/girl/target/classes started by cgc in /home/cgc/Documents/workspace-sts-3.8.3.RELEASE/girl)

2017-08-17 10:27:17.216  INFO 7438 --- [           main] com.example.demo.GirlApplication         : No active profile set, falling back to default profiles: default

2017-08-17 10:27:18.153  INFO 7438 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5b239d7d: startup date [Thu Aug 17 10:27:18 CST 2017]; root of context hierarchy

2017-08-17 10:27:23.699  INFO 7438 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)

2017-08-17 10:27:23.745  INFO 7438 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2017-08-17 10:27:23.746  INFO 7438 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.16

2017-08-17 10:27:24.031  INFO 7438 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2017-08-17 10:27:24.032  INFO 7438 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5902 ms

2017-08-17 10:27:24.656  INFO 7438 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]

2017-08-17 10:27:24.687  INFO 7438 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]

2017-08-17 10:27:24.691  INFO 7438 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]

2017-08-17 10:27:24.692  INFO 7438 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]

2017-08-17 10:27:24.692  INFO 7438 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]

2017-08-17 10:27:24.983  WARN 7438 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

2017-08-17 10:27:24.992  INFO 7438 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

2017-08-17 10:27:25.054  INFO 7438 --- [           main] utoConfigurationReportLoggingInitializer : 


Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.

2017-08-17 10:27:25.103 ERROR 7438 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************

APPLICATION FAILED TO START

***************************


Description:


Cannot determine embedded database driver class for database type NONE


Action:


If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).


正在回答

1 回答

首先去你的 pom.xml里面看看依赖配置对不对,然后看下你的yml,,我的给你参考下

这是pom.xml依赖:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</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-configuration-processor</artifactId>
  <optional>true</optional>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

     <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-jpa</artifactId>
     </dependency>

     <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
     </dependency>

这是yml:

spring:
 profiles:
   active: test
 datasource:
   driver-class-name: com.mysql.jdbc.Driver
   url: jdbc:mysql://localhost:3306/test1
   username: root
   password: root
 jpa:
   hibernate:
     ddl-auto: update
   show-sql: true

这是代码建的表

@Entity
public class Test {


   @Id
   @GeneratedValue
   private Integer  id ;
   private String name;

   public Test(){

   }

   public Integer getId() {
       return id;
   }

   public void setId(Integer id) {
       this.id = id;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

下面是代码controller:

@RestController
@RequestMapping("/test")
public class TestController {
   @Autowired
   private TestList list;

   @RequestMapping("/testList")
   public List<Test> TestList(){
       return list.findAll();
   }

   @RequestMapping("/ListById")
   public Test testById(String id ){
       return list.findOne(Integer.parseInt(id));
   }

   @RequestMapping("/delete")
   public String  deleteTest(Integer  id ){
       list.delete(id);
       return null;
   }
   @RequestMapping("/addTest")
   public Test insertTest(Integer id ,String name){
       Test test=new Test();
       test.setId(id);
       test.setName(name);
     return list.save(test);
   }

   @RequestMapping("/update")
   public Test updateTest(Integer id ,String name){
       Test test=new Test();
       test.setId(id);
       test.setName(name);
       return list.save(test);
   }

对了千万别忘了接口:

public interface TestList extends JpaRepository<Test,Integer>{
 
}


1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
2小时学会Spring Boot
  • 参与学习       151599    人
  • 解答问题       1079    个

Spring Boot入门视频教程,你将学会使用Spring Boot快速构建应用程序

进入课程

请问老师,我的创建了GirlProperties之后,java项目就启动不起来了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信