Apache Shiro JDBC 连接问题

Apache Shiro JDBC Connection Issue

我正在尝试连接到数据库以启动基线用户身份验证程序。我能够使用 shiro.ini 获取用户角色,但在尝试使用 JDBC 连接 运行 程序时出现错误。我也尝试过使用 Microsoft sqljdbc42.jar 和 jTDS jar 文件,结果没有区别。无论哪种方式,我都会收到以下错误:

[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]

我看到了 "No plugin found for prefix" 的几个不同的故障排除问题,但是 'java' none,所以我不知道如何继续。

这是我的 Shiro.ini 文件,使用 jTDS jar:

[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 jar:

<?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>

exec-maven-plugin 的前缀是 exec,因此您可以使用:mvn exec:java。但请注意,您还必须设置 mainClass 才能使其正常工作。