我已经制作了一个Spring starter web项目,需要将它连接到数据库。
在我的pom.xml文件中,我有以下依赖项:
<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.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</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>
对于我的application.properties,我有:
spring.datasource.url = jdbc:mysql://localhost:8889/appname spring.datasource.username = root spring.datasource.password = password spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.testWhileIdle = true spring.datasource.validationQuery = SELECT 1 spring.jpa.show-sql = true spring.jpa.hibernate.ddl-auto = update spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
当我运行应用程序时,服务器运行正常,但是当我转到URL localhost:8889 / appname时,我只是找不到页面错误。
为什么会这样?
我是否正确地说没有必要下载任何其他内容(例如数据库服务器)并且它们都由Spring-Boot处理?