我正在尝试连接到数据库以启动基线用户身份验证程序。我能够使用shiro.ini来获取用户角色,但是在尝试使用JDBC连接运行程序时遇到错误。我也试过使用Microsoft sqljdbc42.jar和jTDS jar文件,但结果没有区别。无论哪种方式,我都会收到以下错误:
[错误]找不到前缀' java'的插件在当前项目和插件组[org.apache.maven.plugins,org.codehaus.mojo]中可从存储库[local(C:\ Users \ mainuser.m2 \ repository),central(https://repo.maven.apache.org/maven2)])获得 - > [帮助1]
我已经看到了针对&#34的几个不同的疑难解答问题;找不到前缀"但是没有“java'”,所以我不知道如何继续。
这是我的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>
答案 0 :(得分:1)
exec-maven-plugin
的前缀为exec
,因此您可以使用:mvn exec:java
。但请注意,您还必须设置mainClass
以允许此操作。