2016-11-21 117 views
0

我正在尝试连接到数据库以启动基准用户身份验证程序。我能够使用shiro.ini来获取用户角色,但是在尝试使用JDBC连接运行程序时出现错误。我曾尝试同时使用Microsoft sqljdbc42.jar和jTDS jar文件,结果没有任何区别。无论哪种方式,我得到以下错误:Apache Shiro JDBC连接问题

[ERROR] No plugin found for prefix 'java' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\mainuser.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

我见过一对夫妇为“找到的前缀无插件”,但没有为“Java”作为不同的故障排除问题,所以我在一个头绪继续。

这里是我的Shiro.ini文件,使用JTDS罐子:

[main] 
ds = net.sourceforge.jtds.jdbcx.JtdsDataSource 
ds.serverName = SQL5 
ds.user = myUser 
ds.password = myPassword 
ds.databaseName = myDatabase 

jdbcRealm = org.apache.shiro.realm.jdbc.JdbcRealm 
jdbcRealm.dataSource = $ds 
jdbcRealm.permissionsLookupEnabled = true 
jdbcRealm.authenticationQuery = "SELECT pswd FROM Users  WHERE user = ?" 
jdbcRealm.userRolesQuery = "SELECT role FROM Role WHERE user = jdbcRealm.permissionsQuery = "SELECT perm FROM Person WHERE user = ?" 

这里是我的pom.xml文件,使用JTDS罐子:

<?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/maven-v4_0_0.xsd"> 

<modelVersion>4.0.0</modelVersion> 
<groupId>org.apache.shiro.tutorials</groupId> 
<artifactId>shiro-tutorial</artifactId> 
<version>1.0.0-SNAPSHOT</version> 
<name>First Apache Shiro Application</name> 
<packaging>jar</packaging> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.0.2</version> 
      <configuration> 
       <source>1.5</source> 
       <target>1.5</target> 
       <encoding>${project.build.sourceEncoding}</encoding> 
      </configuration> 
     </plugin> 

    <!-- This plugin is only to test run our little application. It is not 
     needed in most Shiro-enabled applications: --> 
       <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>exec-maven-plugin</artifactId> 
     <version>1.1</version> 
    </plugin> 
    </plugins> 
</build> 

<dependencies> 
    <dependency> 
     <groupId>net.sourceforge.jtds</groupId> 
     <artifactId>jtds</artifactId> 
     <version>1.3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.shiro</groupId> 
     <artifactId>shiro-core</artifactId> 
     <version>1.1.0</version> 
    </dependency> 
    <!-- Shiro uses SLF4J for logging. We'll use the 'simple' binding 
     in this example app. See http://www.slf4j.org for more info. --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-simple</artifactId> 
     <version>1.6.1</version> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 

回答

1

前缀对于exec-maven-pluginexec,因此您可以使用:mvn exec:java。但请注意,您还必须设置mainClass以允许此操作。

+0

我一直在使用mvn exec:java来运行我的代码。当我不使用JDBC连接时它工作正常,我从[main]中错过了什么? –

+0

我不能相信我犯了这个错误,但我只是意识到我现在使用mvn java:exec而不是mvn exec:java。我现在感觉很傻。 –