我正在尝试使用@Interceptors(SpringBeanAutowiringInterceptor.class)将Spring bean注入EJB
这是我的EJB:
@Stateless
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class processMethodService implements
processMethodService {
@Autowired
private SomeBean bean;
@Schedule(minute = "*/5", hour = "*", persistent = false)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void startProcessing() {
//businesslogic
}
}
Run Code Online (Sandbox Code Playgroud)
和beanRefContext.xml如下
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean id="ejb-businesslayer.application.context" lazy-init="true"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>classpath:/META-INF/spring-config.xml</value>
</list>
</constructor-arg>
</bean> `
Run Code Online (Sandbox Code Playgroud)
beanRefContext.xml,spring-config.xml位于META-INF文件夹下.
当每5分钟调用一次startProcessing时,我们得到以下异常
Exception data: javax.ejb.EJBException: session bean lifecycle interceptor failure;nested exception is:org.springframework.beans.factory.access.BootstrapException: Unable to return specified BeanFactory instance: factory key [null],
from group with resource name [classpath*:beanRefContext.xml];
nested …Run Code Online (Sandbox Code Playgroud) 我想让用户可以切换整个应用程序的颜色皮肤.我的意思是当用户按下屏幕按钮时动态切换应用程序的某些自定义视图的样式.我知道如果你Activity.setTheme()在onCreate()方法之前调用,你可以动态地改变应用程序的主题,但是NavigationView在xml布局上应用了自定义样式的普通视图(例如),没有setTheme或setStyle方法,所以它不会出现可以动态改变他们的风格.
我认为我的目标可能是引用在styles.xml文件中声明的AppTheme中声明的颜色.我的意思是,我可以宣布两个AppThemes,每个都有一组颜色,然后,在为自定义视图声明的自定义样式中,引用颜色.像这样的东西:
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="customColor">#111111</item>
</style>
<style name="AppTheme.AnotherColor" parent="Theme.AppCompat">
<item name="customColor">#222222</item>
</style>
<style name="CustomActionBar">
<!-- title text color -->
<item name="android:textColorPrimary">@styles/customColor</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
因此,默认情况下,我的"AppTheme"上声明的自定义Color将默认使用颜色应用111111.但是,当我使用应用setTheme(R.styles.AppTheme_AnotherColor)的颜色更改我的应用程序的主题时222222.如果这是可能的,那将是完美的!但它不可能或者我不知道如何直接从同一styles.xml文件的另一种样式访问样式中声明的颜色.我的意思@styles/customColor是不正确,我不知道如何访问这种颜色.
怎么能实现这一目标?
我对Spring Boot非常陌生,我正在尝试掌握它的概念。现在我遇到了@Autowired。我对此非常了解。
就像,当您编写@Autowired时,事情发生在两次通过中,而在第二次通过中,spring注入了bean。
现在,我有这个例子。
Class Abc {
@Autowired
private Xyz xyz;
PSVM(String...z) {
xyz.hello();
}
}
Run Code Online (Sandbox Code Playgroud)
导入基本上将代码导入文件中。
所以,
Import com.tilak.Xyz;
Class Abc {
private Xyz xyz;
PSVM(String...z) {
xyz = new Xyz();
xyz.hello();
}
}
Run Code Online (Sandbox Code Playgroud)
为什么我不应该选择后者呢?
做第一个有什么好处吗?我应该在哪里使用第一个?
我已经实现了一个 apache 骆驼调度程序,它以固定的时间间隔执行任务。现在要执行的任务数量已经增加,我很困惑是否继续使用相同的方法或创建多个路线构建器。
现在的方法是,调用数据库获取所有配置的其余详细信息,并在 routerbuilder 的 confuguire 方法中迭代并构建路由。
代码示例:
public void configure() {
for(int i=0; i< list.length;i++){
from("quartz://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1")
.setBody().simple("Current time is ${header.firedTime}")
.to("stream:out");
}
}
Run Code Online (Sandbox Code Playgroud)
这里我只有一个路由构建器类,配置方法具有创建多个路由的 for 循环。