springboot 连接sqlserver
Posted Bigben
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot 连接sqlserver相关的知识,希望对你有一定的参考价值。
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.0chsjre8)。在有sqljdbc4.jar包的文件夹下,通过shift+右键的方式–>此处打开命令窗口,然后执行以下maven命令:
mvn install:install-file -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.2 -Dpackaging=jar -Dfile=E:sqljdbc_6.0chsjre8sqljdbc42.jar
显示build success,mvn库文件会放在C:UsersAdministrator.m2 epositorycommicrosoftsqlserver
3,pom.xml中添加依赖
<!-- sqlserver connector -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<scope>4.2</scope>
<version>4.2</version>
</dependency>
以上是关于springboot 连接sqlserver的主要内容,如果未能解决你的问题,请参考以下文章
3.springboot:springboot配置文件(配置文件YAML属性文件值注入<@Value@ConfigurationProperties@PropertySource,@Im(代码片
3springboot:springboot配置文件(配置文件YAML属性文件值注入<@Value@ConfigurationProperties@PropertySource,@Imp(代码片
springboot配置文件application-dev.properties,application-prod.properties,application-test.properties(代码片
springboot报错说 Failed to parse multipart servlet request; nested exception is java.io.IOException(代码片
SpringBoot MAVEN编译报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:(代码片