1,配置application.properties
#sqlserver configure spring.datasource.url =jdbc:sqlserver://localhost:1433;DatabaseName=myDatabase spring.datasource.username=sa spring.datasource.password=sa spring.datasource.driverClassName =com.microsoft.sqlserver.jdbc.SQLServerDriver spring.jpa.database=SQLSERVER spring.jpa.properties.hibernate.default_schema=dbo #database name spring.jpa.properties.hibernate.default_catalog=myDatabase # spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2008Dialect # Naming strategy spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.hibernate.ddl-auto=create-drop #spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.h2geodb.GeoDBDialect #spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect spring.jpa.show-sql=true spring.datasource.platform=mysql logging.level.org.hibernate.SQL=DEBUG logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE logging.level.org.hibernate.type=TRACE
2, 在maven中添加sql server的jdbc驱动包
官网下载sqljdbc4的jar包
解压到任意位置(win:E:\sqljdbc_6.0\chs\jre8)。在有sqljdbc4.jar包的文件夹下,通过shift+右键的方式–>此处打开命令窗口,然后执行以下maven命令:
mvn install:install-file -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.2 -Dpackaging=jar -Dfile=E:\sqljdbc_6.0\chs\jre8\sqljdbc42.jar
显示build success,mvn库文件会放在C:\UsersAdministrator\.m2\repository\com\microsoft\sqlserver
3,pom.xml中添加依赖
<!-- sqlserver connector -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<scope>4.2</scope>
<version>4.2</version>
</dependency>
原文地址:https://www.cnblogs.com/bigben0123/p/9792153.html
时间: 2024-09-28 20:13:46