我想尝试以下列方式使用@Schedule注释:
public class MyTestServlet extends HttpServlet {
private static JcanLogger LOG = JcanLoggerFactory.getLogger(ServiceTestServlet.class);
@EJB CronService cronService;
public void service(HttpServletRequest req, HttpServletResponse resp) throws .... {
....
cronService.iLive();
}
---
@Local // because the ejb is in a servlet (there is no other jvm)
public interface CronService {
public void iLive();
public void runsEveryMinute();
}
---
@Singleton
public class CronServiceBean implements CronService {
private static final JcanLogger LOG = JcanLoggerFactory.getLogger(CronServiceBean.class);
@Schedule(minute="*")
public void runsEveryMinute() {
LOG.info(" runs EveryMinute ");
}
public …Run Code Online (Sandbox Code Playgroud) 我试图在一个小型独立应用程序中一起使用spring数据和spring配置.
...
public static void main( String[] args )
{
ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
...
}
Run Code Online (Sandbox Code Playgroud)
1.我的问题是如何在不使用的情况下发现spring数据存储库
<jpa:repositories base-package="foo.repositories" />
Run Code Online (Sandbox Code Playgroud)
通过spring config?
2.如果没有,我可以以某种方式一起使用'ClassPathXmlApplicationContext'和'AnnotationConfigApplicationContext'吗?
也许,由于我的英语错误,我无法理解使用@Autowired注释的好处.
根据教程,我们可以通过@Autowired将第一个(I.)案例简化为第二个案例(II.).
我的问题是,@ Autowired是什么意思?因为它不再告诉,因为不使用@Autowired,编译器可以根据声明得出"EmpDao emDao"和"EmpManager"密切相关.
从这里引用的代码
一世.
<bean id="empDao" class="EmpDao" />
<bean id="empManager" class="EmpManager">
<property name="empDao" ref="empDao" />
</bean>
public class EmpManager {
private EmpDao empDao;
public EmpDao getEmpDao() {
return empDao;
}
public void setEmpDao(EmpDao empDao) {
this.empDao = empDao;
}
...
}
Run Code Online (Sandbox Code Playgroud)
II.
<context:annotation-config />
<bean id="empManager" class="autowiredexample.EmpManager" />
<bean id="empDao" class="autowiredexample.EmpDao" />
import org.springframework.beans.factory.annotation.Autowired;
public class EmpManager {
@Autowired
private EmpDao empDao;
}
Run Code Online (Sandbox Code Playgroud) 我正在读一本关于Java EE 6的书,我遇到了以下几个部分:
"无状态:会话bean在方法之间不包含会话状态,任何实例都可以用于任何客户端."
"有状态:会话bean包含会话状态,必须在单个用户的方法中保留."
"会话状态"是什么意思?有人用现实世界的例子来解释它吗?
提前致谢.
II.为什么豆类的这种分类如此重要?无论是正确的解释还是初学者(乍看之下)都没有说明任何事情.所以,多亏了你,我得到了逻辑上的区别,但为什么这种行为如此重要呢?
如何将当前命名空间焦点更改为Spring Roo控制台中的实体?
那么,我该怎样才能离开
roo>
Run Code Online (Sandbox Code Playgroud)
至
~.domain.Price roo>
Run Code Online (Sandbox Code Playgroud)
然后回来?
感谢您提前的答案.
铯.
我有一个m:n关系书 - 借用 - 用户,借用是连接表.
表格给出(不能更改):
book(book_id) - 借(book_id,used_id) - 用户(user_id)
used jpa annotations:
User:
@OneToMany(targetEntity=BorrowEntity.class, mappedBy="user")
@JoinColumn(name="USER_ID", referencedColumnName="USER_ID")
private List<BorrowEntity>borrowings;
Book:
@OneToMany(targetEntity=BorrowEntity.class, mappedBy="book")
@JoinColumn(name="BOOK_ID", referencedColumnName="BOOK_ID")
private List<BorrowEntity>borrowings;
Run Code Online (Sandbox Code Playgroud)
我的问题是,通过上面的设置,它会向借位表添加一些额外的(不需要的)字段:
'user_USER_ID'和'book_BOOK_ID'
我怎样才能配置jpa注释以保持Borrow:user_id,book_id哪个足够多?
看看更多的图片:

我试图在选择列表更改时捕获,但是当我打开选择列表时触发以下代码,而不是在选择新列表项时.
this.select.addListener(new Property.ValueChangeListener() {
public void valueChange(ValueChangeEvent event)
{
System.out.println(event.getProperty());
}
});
Run Code Online (Sandbox Code Playgroud)
为什么我错了,我怎样才能及时捕捉每一个新的选定值?
发生了什么(youtube video - temporary)http://goo.gl/m7dNi
感谢您提前的答案.
铯
有人可以解释一下"用Java接口隐藏api"是什么意思吗?如何通过接口使用API函数?我需要一个小的工作示例来了解接口如何隐藏api非公共部分,以及如何在同一时间使用api puplic部分.
提前致谢.
感谢快速回复,让我有时间思考答案.
最后但不要感谢你的时间和努力!
II.我的第二个问题是:在下面这个案例的背景下会发生什么?
IBinaryOperation op = BinaryOperationProvider.getOperation("multiply");
or
List<String> myList = new LinkedList<String>();
Run Code Online (Sandbox Code Playgroud)
对我来说不清楚,因为接口包含方法的声明,这就是为什么我不理解上面的行中可能发生的事情.使用的接口和对象的空方法之间是否存在任何含义?抱歉我的英语不好.
我有一个自己的类(ClassFoo)与一个简单的属性(pName),我无法设置它,因为我总是得到错误...
Class Modules - ClassFoo
---
Public pName as String
Public Property Let Name(Value as String)
pName = Value
End Property
----
Somewhere else in the ModuleX
...
Dim Foo as ClassFoo
Foo.Name = "foo" <- throws error
Foo.pName = "foo" <- throws error
Run Code Online (Sandbox Code Playgroud)
要么
With Foo
.pName = "foo" <- throws error
End With
Run Code Online (Sandbox Code Playgroud)
我将班级'Instancing'从'Private'更改为'PublicNotCreatable'(来回)但我仍然有同样的错误......
感谢您提前回复.
铯
我希望更新同一个表的某些行.据我所知,以下形式在MySQL下不起作用
UPDATE footbl SET foocol=something WHERE foocol in (SELECT ft.foocol ... bla bla )
Run Code Online (Sandbox Code Playgroud)
MySQL论坛的一篇帖子暗示:使用子查询.
所以我的解决方案是:
SELECT @data:=f2.fname ... bla bla
UPDATE tfile2 SET fstatus='deleted' WHERE tfile2.fname=(@data);
Run Code Online (Sandbox Code Playgroud)
但是,不幸的是,如果子查询@data占用多行,那么在我的情况下只更新一行.!看看这张照片!
那么,我错了什么,如何在同一个表上更新多行?
感谢您的努力和提前的时间.
乔鲍
如果我的代码中有异常处理部分,并且它可以触发4个sqlException,那么处理它们的最佳方法是什么,它最能说明发生了什么以及在哪里?我制作了一个穷人解决方案(使用'exceptionDesc').
处理这种情况有什么好的做法吗?(没有制作独特的类和子类)
try {
exceptionDesc = "prepareStatement";
statement = connection.prepareStatement(sql);
exceptionDesc = "statement.set...";
statement.setDate(1, sqlDate);
exceptionDesc = "executeUpdate";
statement.executeUpdate();
exceptionDesc = "commit";
connection.commit();
}
catch (SQLException sqlEx) {
if (exceptionDesc.equals("prepareStatement")) {
LOG.error ...
} else if (exceptionDesc.equals("executeQuery")) {
LOG.error(" executeQuery ...
...
...
throw new SQLException(sqlEx);
}
Run Code Online (Sandbox Code Playgroud) java ×5
spring ×2
annotations ×1
api ×1
autowired ×1
ejb ×1
ejb-3.0 ×1
excel ×1
excel-2010 ×1
interface ×1
java-ee ×1
java-ee-6 ×1
jpa ×1
many-to-one ×1
mysql ×1
prompt ×1
schedule ×1
selection ×1
spring-data ×1
spring-roo ×1
subquery ×1
vaadin ×1
vba ×1