i intended to pack my action classes in jar file and utilize the convention plugin to initialize them. i did it following
this instruction.
the plugin didn't recognize my jar file. >_<
with the source code of convention plugin, i traced to
org.apache.struts2.convention.PackageBasedActionConfigBuilder
private UrlSet buildUrlSet() throws IOException {
ClassLoaderInterface classLoaderInterface = getClassLoaderInterface();
UrlSet urlSet = new UrlSet(classLoaderInterface, this.fileProtocols);
//...
//removed the rest of codes
}
i found my jar in the
classLoaderInterface but the
urlSet didn't recognize it. let's dig deeper. it's a class in xwork. the xwork 2.1.6 release is not updated on the official site.
here is the address.
com.opensymphony.xwork2.util.finder.UrlSet
private static List<URL> getUrls(ClassLoaderInterface classLoader) throws IOException {
List<URL> list = new ArrayList<URL>();
//find jars
ArrayList<URL> urls = Collections.list(classLoader.getResources("META-INF"));
//...
//removed the rest of codes
}
classLoader.getResources("META-INF") - this is how xwork finds jar files. spring does it with the same approach and luckily someone(Ingo Düppe) from their side gave us a heads-up on the
META-INF.
http://jira.springframework.org/browse/SPR-1670
引用
Please be careful with this approach. Not all jar files do have a META-INF directory entry even when files exists like META-INF/manifest.mf. For instance jars build with eclipse do not contain a META-INF directory entry so this approach will not find these jars.
thanks Ingo! you save my day.
turns out that my jar was built with eclipse export tool and had no directory entry of the META-INF folder. i packed it again with ant task then the plugin found it.
分享到:
相关推荐
struts2-convention-plugin-2.3.15.1.jar
struts2-convention-plugin-2.1.6.jar
Struts2 Convention Plugin 是从 Struts2.1 版本开始引入的一个插件,它的主要目标是实现 Struts2 框架的零配置。通过约定优于配置的原则,开发者可以更加专注于业务逻辑,减少大量的 XML 配置工作。以下是 ...
struts2-convention-plugin-2.1.8.jar
不论高低版本,要使用struts2-core这个jar包,当又需struts2-convention-plugin.jar时勿必要使两者版本一致哦,否则会有DefError、Unable to read class诸等错误
struts2-convention-plugin-2.3.1.jar,使用注解的方式代替xml配置action,必须要引用这个包。
struts2-convention-plugin-2.3.24.1
struts2-convention-plugin-2.3.1.2.jar
struts2-convention-plugin-2.3.24.jar
在给定的文件"struts2-convention-plugin-2.3.32.jar"中,我们关注的是Struts2的Convention插件,版本号为2.3.32。这个插件是Struts2框架的一个重要组成部分,旨在提供更加灵活和自动化的配置方式。 Convention...
2.5.10.1.jar,struts2-config-browser-plugin-2.5.10.1.jar,struts2-convention-plugin-2.5.10.1.jar,struts2-dwr-plugin-2.5.10.1.jar,struts2-embeddedjsp-plugin-2.5.10.1.jar,struts2-gxp-plugin-2.5.10.1....
struts2-convention-plugin-2.1.8.1.jar
2. **struts2-convention-plugin**: 自动配置插件,根据命名约定自动发现Action类和结果页面,减少了XML配置的需要。 3. **struts2-json-plugin**: 提供了对JSON格式数据的支持,使得Action可以直接返回JSON响应,...
struts2-convention-plugin-2.3.4.1.jar
Struts2 Convention Plugin是Apache Struts框架的一个重要插件,主要目标是简化MVC(Model-View-Controller)架构中的配置工作。这个插件引入了一种约定优于配置(Convention over Configuration)的理念,允许...
struts2-convention-plugin-2.3.15.3.jar struts2配置Action注解要用到的包,真正实现零配置
然而,随着版本的更新,Struts2引入了一个名为Convention Plugin的新特性,旨在简化配置过程,实现所谓的“零配置”开发。 **什么是Struts2 Convention Plugin?** Convention Plugin是Struts2的一个插件,它基于...
5. **struts2-convention-plugin.jar**:该插件实现了“约定优于配置”的原则,可以自动根据类名和方法名生成Action配置,简化了开发过程。 6. **struts2-dojo-plugin.jar** 和其他UI插件:这些插件提供了与特定...