我需要为我的客户生成一个简单的应用程序,并在他们的网站上运行.我正在使用Spring框架,所以我有许多必须在类路径上的配置文件.我使用Maven2和Netbeans作为我的IDE.
我能够使用Netbeans/Maven创建和运行我的应用程序,并且我使用Application Assembler Maven插件来生成可运行的应用程序.所有这一切都很好,除了我的Spring配置文件必须放在src/main/resources中,这意味着它们被打包到生成的JAR文件中.
我需要我的客户能够修改配置文件以进行测试,但要求他们修改JAR中打包的副本是不合理的.
可能有许多解决方案,但在我看来,最简单的方法是让Maven根本不将应用程序和配置文件打包到JAR中,只需将它们保存在类目录中就可以了.跑.这将允许用户轻松修改配置文件.不幸的是,我无法弄清楚如何让Maven以这种方式"打包"应用程序,或者如何让AppAssembler生成生成的runnable.
这是我的pom.xml的摘录,可能有助于说明我想要做的事情:
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
... stuff deleted ...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<!-- Set the target configuration directory to be used in the bin scripts -->
<configurationDirectory>conf</configurationDirectory>
<!-- Copy the contents from "/src/main/config" to the target
configuration directory in the assembled application -->
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<!-- Include the target configuration directory in the beginning …Run Code Online (Sandbox Code Playgroud) 我正在为第三方API提供一些外观类,我需要包装一个迭代器,以便我可以替换用我自己的外观对象迭代的东西.
这是我的facade类的简化版本,它包装了一个名为Item的API类
class FacadeItem {
Item item;
FacadeItem(Item item) {
this.item = item;
}
}
Run Code Online (Sandbox Code Playgroud)
API提供此表单的迭代器 Iterator<Item>
我需要实现此形式Iterator<FacadeItem>的迭代器,该迭代器由API的迭代器支持.
我考虑过如下使用Guava库中的ForwardingIterator:
class FacadeItemIterator<FacadeItem> extends ForwardingIterator<Item> {
final Iterator<Item> delegate; // backing iterator
FacadeItemIterator(Iterator<Item> delegate) {
this.delegate = delegate;
}
@Override protected Iterator<Item> delegate() {
return delegate;
}
@Override
public FacadeItem next() {
return new FacadeItem(super.next());
}
}
Run Code Online (Sandbox Code Playgroud)
但next()编译器不允许覆盖,因为它期望返回的类型是Item,而不是FacadeItem
这是一个简单的例子,在同一目录中有两个 bat 文件 caller.bat 和 callee.bat。
调用者.bat
call callee.bat
pause
Run Code Online (Sandbox Code Playgroud)
被调用者.bat
echo "All good"
Run Code Online (Sandbox Code Playgroud)
当我通过在资源管理器中双击 caller.bat 运行它时,它按预期工作,但如果使用右键单击“以管理员身份运行”,我会得到
'callee.bat' 未被识别为内部或外部命令...