我正在进行下一个测试:
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/META-INF/spring/applicationContext.xml" })
public class FloorServiceTest {
@Autowired
private FloorService floorService;
@Test
public void testFloorService() {
floorService.findById((long)1);
}
}
Run Code Online (Sandbox Code Playgroud)
用文件applicationContext.xml夹下的文件/APP/src/main/resources/META-INF/spring/
但似乎没有正确地自动装配bean:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.confloorapp.services.FloorServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.confloorapp.services.FloorService com.confloorapp.services.FloorServiceTest.floorService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.confloorapp.services.FloorService] found for dependency: expected at least …Run Code Online (Sandbox Code Playgroud) 我想使用 PuTTY 程序连接我的串口,但这是不可能的,当我点击“打开”时什么也没有发生。在 Mac OS X 和 VirtualBox 的 Windows 7 下,我只听到“哔哔哔”的声音

当组合框值发生变化时,我想获得组合框的旧值。
我尝试过类似的事情:
Private Sub ComboBox1_Change()
Application.EnableEvents = False
newVal = ComboBox1.Value
Application.Undo
oldVal = ComboBox1.Valu
End Sub
Run Code Online (Sandbox Code Playgroud)
或者
Private Sub ComboBox1_Change()
Application.EnableEvents = False
newVal = ComboBox1.Value
ComboBox1.Undo
oldVal = ComboBox1.Valu
End Sub
Run Code Online (Sandbox Code Playgroud)
但它似乎不起作用......
谢谢
我试图从数据库中的对象做一个简单的加载,但我得到错误"无法初始化代理 - 没有会话",任何想法?谢谢
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.jav a:167)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
com.myapp.domain.User_$$_javassist_0.getLogin(User_$$_javassist_0.java)
com.myapp.validator.UserFormValidator.validate(UserFormValidator.java:34)
Run Code Online (Sandbox Code Playgroud)
@Component
public class UserFormValidator implements Validator {
@Autowired
private UserDAO userDAO;
@Override
public boolean supports(Class<?> clazz) {
return UserForm.class.equals(clazz);
}
public UserDAO getUserDAO() {
return userDAO;
}
public void setUserDAO(UserDAO userDAO) {
this.userDAO = userDAO;
}
@Override
public void validate(Object target, Errors errors) {
User user = (User)getUserDAO().findById(new Integer(1));
System.out.println ("User -> " + user.getLogin());
}
}
Run Code Online (Sandbox Code Playgroud)
@Transactional
public class GenericDAOHibernateImpl <T, PK …Run Code Online (Sandbox Code Playgroud) 如果我使用@Autowired,这个servlet中的服务为null,它使用context.getBean(); 此外,使用/ floorOperationWS /的映射没有完成,我必须在web.xml中定义映射.
package com.confloorapp.services.endpoint;
import java.io.IOException;
import java.util.Date;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
@WebServlet(value = "/floorOperationWS/")
public class UpdateFloorEventServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
FloorService floorService = (DoorService)context.getBean("floorService");
}
}
Run Code Online (Sandbox Code Playgroud)
这里是applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd">
<!-- Activates various annotations to be …Run Code Online (Sandbox Code Playgroud)