maven Web项目添加数据源支持,包括Oracle、Mysql
pom.xml 支持jkbc:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency>
Oracle:
pom.xml:
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>12.1.0.1-atlassian-hosted</version> </dependency>
application.properties:
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl spring.datasource.username=userstudy spring.datasource.password=userstudy spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
MySql:
pom.xml:
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.21</version> </dependency>
application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.Driver