2015-06-01 105 views
0

我想使用Hibernate和SQL Server 2008.我遇到過安裝sqljdbc4到我的本地Maven倉庫。它給了我一個錯誤,我無法前進。休眠和SQL Server依賴

我不知道我的本地庫應該怎麼樣子(新手),但MVN指令給出錯誤:

[ERROR] Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:m 
aven-install-plugin:jar:2.4: Failure to transfer org.apache.maven.plugins:maven-install-plugin:pom:2.4 from https://repo.maven.apache.org/maven2 was cached in the local repository, 
resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:mav 
en-install-plugin:pom:2.4 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpa 
th.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1] 
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Failed to read artifac 
t descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.4 
     at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:122) 
     at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:150) 
     at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:269) 
     at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:239) 
     at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:233) 
     at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:103) 
     at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:83) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:85) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) 
     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) 
     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:160) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:606) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven.plugins:maven-install-plugin:jar:2.4 
     at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:302) 
     at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217) 
     at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:287) 
     at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:108) 
     ... 20 more 
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Failure to transfer org.apache.maven.plugins:maven-install-plugin:pom:2.4 from https://repo.maven.apache.org/m 
aven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not trans 
fer artifact org.apache.maven.plugins:maven-install-plugin:pom:2.4 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path buil 
ding failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
     at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444) 
     at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246) 
     at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223) 
     at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:287) 
     ... 23 more 
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer org.apache.maven.plugins:maven-install-plugin:pom:2.4 from https://repo.maven.apache.org/maven 
2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer 
artifact org.apache.maven.plugins:maven-install-plugin:pom:2.4 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building 
failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
     at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238) 
     at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:183) 
     at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585) 
     at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503) 
     at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421) 
     ... 26 more 
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException 
+0

當您嘗試在本地回購站中安裝sqljdbc4時會出現此錯誤? – Arpit

+0

你能提供你的pom.xml顯示 – ManojP

+0

com.microsoft.sqlserver sqljdbc4 4.0 FioLynaly

回答

0

我找到了答案而回,但只是認爲這是公平的張貼這裏。

<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property> 
    <property name="hibernate.connection.url">jdbc:jtds:sqlserver://server/db</property> 
    <property name="hibernate.connection.username">here</property> 
    <property name="hibernate.connection.password">here</property> 
    <property name="hibernate.connection.pool_size">100</property> 
    <property name="show_sql">false</property> 
    <property name="dialect">org.hibernate.dialect.SQLServerDialect</property> 
0

你有triend安裝命令這樣嗎?在命令

mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 

典型行家輸出

[INFO] Scanning for projects... 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Maven Stub Project (No POM) 1 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom --- 
[INFO] Installing c:\Data\****\****\temp\sqljdbc4.jar to C:\Users\****\.m2\repository\com\microsoft\sqlserver\sqljdbc4\4.0\sqljdbc4-4.0.jar 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 0.458 s 
[INFO] Finished at: 2015-06-01T15:40:03+02:00 
[INFO] Final Memory: 7M/241M 
[INFO] ------------------------------------------------------------------------ 

Maven的依賴關係應該是這樣的:

<dependency> 
    <groupId>com.microsoft.sqlserver</groupId> 
    <artifactId>sqljdbc4</artifactId> 
    <version>4.0</version> 
</dependency> 

在安裝sqljdbc4到本地倉庫另一種選擇是從本地文件系統中引用它,但有一些限制 - path是相對於特定的maven模塊。在項目之一,我把sqljdbc在references目錄是在同一水平行家modules目錄,並添加它,如下所示:

<dependency> 
    <groupId>com.microsoft.sqlserver</groupId> 
    <artifactId>sqljdbc4</artifactId> 
    <version>4.0</version> 
    <scope>system</scope> 
    <systemPath>${project.basedir}/../references/sqljdbc4.jar</systemPath> 
</dependency> 
+0

嗨@Viktor,我一直在努力的是sqljdbc4依賴。我不確定問題出在哪裏。 mvn命令嘗試下載,然後顯示上面的錯誤。 – FioLynaly

+0

剛剛嘗試過我在Windows環境下Maven 3.2.3上建議的命令。我編輯了我的答案並添加了Maven生成的輸出。我不知道爲什麼它不適合你,可能是不同的版本或者是拼錯的命令。 –