我有通过maven构建rpm的java项目.必需创建noarch包,但我看到具体的拱.我在MacOsX上通过macports安装rpm(4.4.9或5.2.0),并从maven rpm插件运行命令:
sudo rpmbuild -bb -v --buildroot /path/to/project/buildroot --target noarch java-search-qt.spec Building target platforms: noarch Executing(%install): /bin/bash -e /tmp/rpm-tmp.69257 + umask 022 + cd /opt/local/src/macports/BUILD + /bin/rm -rf /path/to/project/target/rpm/project/buildroot + /bin/rm -rf /path/to/project/target/rpm/project/buildroot + '[' -e /path/to/project/target/rpm/project/buildroot ']' + mv /path/to/project/target/rpm/project/tmp-buildroot /path/to/project/target/rpm/project/buildroot + /opt/local/lib/rpm/brp-compress + /opt/local/lib/rpm/brp-strip + /opt/local/lib/rpm/brp-strip-static-archive + /opt/local/lib/rpm/brp-strip-comment-note + /opt/local/lib/rpm/brp-nobuildrootpath Processing files: java-search-qt-1.0.17-1 Finding Provides: /opt/local/lib/rpm/find-provides Finding Requires: /opt/local/lib/rpm/find-requires Requires(interp): /bin/bash /bin/bash /bin/bash /bin/bash Requires(verify): /bin/bash Requires(pre): /bin/bash Requires(post): /bin/bash Requires(postun): /bin/bash Checking for unpackaged file(s): /opt/local/lib/rpm/check-files /path/to/project/target/rpm/project/buildroot …
我有懒惰初始化bean的代码:
@Component @Lazy
class Resource {...}
@Component @Lazy @CustomProcessor
class ResourceProcessorFoo{
@Autowired
public ResourceProcessor(Resource resource) {...}
}
@Component @Lazy @CustomProcessor
class ResourceProcessorBar{
@Autowired
public ResourceProcessor(Resource resource) {...}
}
Run Code Online (Sandbox Code Playgroud)
初始化应用程序上下文后,没有此bean的实例.当bean资源由应用程序上下文创建时(例如,applicationContext.getBean(Resource.class)),没有@CustomProcessor实例标记bean.
在创建Resource bean时,需要使用@CustomProcessor创建bean.怎么做?
更新:找到一个丑陋的解决方案 - 使用空的自动装配的setter:
@Autowired
public void setProcessors(List<ResourceProcessor> processor){}
Run Code Online (Sandbox Code Playgroud)
Bean BeanPostProcessor的另一个丑陋的解决方案(太神奇了!)
@Component
class CustomProcessor implements BeanPostProcessor{
public postProcessBeforeInitialization(Object bean, String beanName) {
if(bean instanceof Resource){
applicationContext.getBeansWithAnnotation(CustomProcessor.class);
}
}
}
Run Code Online (Sandbox Code Playgroud)
也许有更优雅的方式?