我在运行Spring启动应用程序时遇到异常,它说无法创建数据源bean,导致此异常的原因是它无法检测到SQLServer的DriverClass.
这是我的application.properties文件:
spring.jpa.database-platform=org.hibernate.dialect.SQLServerDialect
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=dbname
spring.datasource.username=name
spring.datasource.password=****
Run Code Online (Sandbox Code Playgroud)
我已经下载了sqljdbc连接器jar并将其放在lib文件夹中,并在我的pom.xml文件中提供它的引用.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproject</groupId>
<artifactId>myproject-notifications</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>netpace-notifications</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</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.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/sqljdbc4-2.0.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins> …Run Code Online (Sandbox Code Playgroud) 我有一些字符串,其中一些xml驻留.
字符串是:
string xmlRead = "<ns0:RequestedAmount xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\"> <ns0:RequestedAmount></ns0:RequestedAmount> </ns0:RequestedAmount>" +
"<ns0:Response xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\"> <ns0:Response/> </ns0:Response>" +
"<ns0:isValid xmlns:ns0=\"http://tempuri.org/XMLSchema.xsd\"> <ns0:isValid/> </ns0:isValid>";
Run Code Online (Sandbox Code Playgroud)
我试过这个:
string s=xmlRead.Replace(@"\","");
string s=xmlRead.Replace("\"","");
string s=xmlRead.Replace(@"\",string.Empty);
Run Code Online (Sandbox Code Playgroud)
什么都没有帮助我帮助我在这里做错了什么.
我正在使用实体框架来获取包含数百万条记录的表的简单行计数,并且我不需要任何 where 子句。我尝试使用 Count 方法,但获取计数需要很长时间。有没有什么有效的方法可以在等待那么长时间的情况下获取计数?
我有一个字符串,我必须将其转换为DateTime类型.
'11 Jun 2015 (12:10)'
Run Code Online (Sandbox Code Playgroud)
我必须将其解析为DateTime.我已经使用DateTime.Parse("MyDateString")但它抛出一个例外.
字符串未被识别为有效的DateTime.
我必须拆分字符串而不是将其转换为DateTime格式或者有一种简单的方法吗?