我想开始开发一个众包插件。该插件必须连接到 AD 搜索用户并获取 AD 的特定属性。所以我开始关注这个。我已经为我过去开发的 JIRA 插件安装了 Atlassian-SDK。所以我创建了一个新插件
atlas-create-crowd-plugin
在我删除了 create 命令从我创建并复制到示例代码中的类之后,但这不起作用(编译问题)。所以我改变了一点 pom.xml
<? 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>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<version>1.0-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>event-listener-example</name>
<description>This is an event listener plugin for Atlassian Crowd.</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.crowd</groupId>
<artifactId>crowd-events</artifactId>
<version>${crowd.version}</version>
<cope>provided</scope>
<dependency>
<dependency>
<groupId>com.atlassian.event</groupId>
<artifactId>atlassian-event</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-crowd-plugin</artifactId>
<version>6.2.1</version>
<extensions>true</extensions>
<configuration>
<productVersion>${crowd.version}</productVersion>
<productDataVersion>${crowd.data.version}</productDataVersion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<configuration>
</plugin>
</plugins>
</build>
<properties>
<crowd.version>2.8.4</crowd.version>
<crowd.data.version>2.8.4</crowd.data.version>
<atlassian.plugin.key>${project.groupId}.${project.artifactId} </atlassian.plugin.key>
</properties>
</project>
在这里你可以看到我对它做了一点改动(版本,并添加了 atlassian-event 依赖项)。
然后我改变了 atlassian-plugin.xml :
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}"
plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version</version>
<vendor name="${project.organization.name}"
url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<resource type="i18n" name="i18n" location="kgSynchro" />
<listener name="User Created Listener" key="usercreatedlistener"
class="myPackage.NewUserEventListener">
<description>Will listen for user creation
events.</description>
</listener>
</atlassian-plugin>
最后我的课:
package myPackage.events;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atlassian.crowd.event.user.UserCreatedEvent;
import com.atlassian.event.api.EventListener;
public class NewUserEventListener {
private final Logger log = LoggerFactory.getLogger (NewUserEventListener.class);
@EventListener public void printUserCreatedEvent(
UserCreatedEvent event) {
System.out.println("User " + event.getUser ().getDisplayName() + " has been created.");
log.error("new User is CREATED");
}
}
与示例相同,但我添加了 Logger 来记录方法的调用。
然后我用 atlas-run 启动了 crod 环境(也尝试了 atlas-debug),然后我转到用户 UI 并尝试添加一个新用户。用户已正确创建,但在日志上没有出现关于我的方法的任何内容。我有很多错误:
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
但这发生在我在人群中导航的每个页面上......然后我认为这与我的方法从未被调用这一事实无关。
每个人都有一些关于如何找出问题的提示吗?
坦克非常提前