儘管Maven解決了依賴關係,並且它在我的項目設置中顯示爲模塊(因此應該在類路徑中),但IntelliJ不允許我導入com.microsoft。IntelliJ無法找到從Maven的sqljdbc4.jar即使它解決?
POM文件中有這樣的:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.arcologydesigns.rest</groupId>
<artifactId>ads-webapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springexample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<spring.version>4.0.5.RELEASE</spring.version>
<jdk.version>1.8</jdk.version>
<jackson.version>2.2.3</jackson.version>
<!--<sqlserver.version>4.2.6420.100</sqlserver.version>-->
<sqlserver.version>4</sqlserver.version>
<build.scm.revision>SCM_IDENTIFIER</build.scm.revision>
<build.number>BUILD_NUMBER</build.number>
<build.id>BUILD_ID</build.id>
<build.job.name>BUILD_JOB_NAME</build.job.name>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>${sqlserver.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20120521</version>
</dependency>
</dependencies>
<build>
<finalName>ads-webapp</finalName>
</build>
</project>
我用下面安裝了sqljdbc驅動程序(這是我從MSDN下載) Maven:http://techmajik.com/2014/04/24/how-to-setup-maven-dependency-for-microsoft-sql-server/
該鏈接不再有效。搜索「sqljdbc4」並顯示Microsoft下載頁面。解壓縮下載,然後運行maven命令。 – scottheckel