我很困惑.javax.inject.Singleton和之间的确切区别是javax.ejb.Singleton什么?
当我想启动Hibernate应用程序时,我总是得到类型安全警告.有没有一种方法可以摆脱这个没有使用@SuppressWarnings("unchecked")?
这是我的代码:
Configuration config = new Configuration();
config.addAnnotatedClass(Employee.class);
config.configure("hibernate.cfg.xml");
new SchemaExport(config).create(false, false);
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(config.getProperties()).build();
SessionFactory factory = config.buildSessionFactory(serviceRegistry);
Session session = factory.getCurrentSession();
session.beginTransaction();
Query q = session
.createQuery("SELECT e.empId,e.empName FROM Employee e");
@SuppressWarnings("unchecked")
List<Object[]> list = q.list(); <-- here is the problem!
Run Code Online (Sandbox Code Playgroud) 我尝试在Junit测试用例中使用Springs自己的依赖注入:
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.binarisinformatik.api.AppConfig;
import org.binarisinformatik.satzrechner.SatzRechner;
import org.junit.Before;
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(classes=AppConfig.class)
//@SpringApplicationConfiguration(classes = {AppConfig.class})
public class SatzRechnerTest {
@Autowired
private SatzRechner satzRechner; //SUT
@Before
public void setUp() {
// AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SatzRechnerTest.class);
//satzRechner=context.getBean(SatzRechner.class);
}
@Test
public void addiere_satz_4komma6_zu_zahlwert_10() {
assertThat("Addition von \"4,6\" ergibt nicht 10!",
satzRechner.summe("4,6"), is(equalTo(10)));
}
Run Code Online (Sandbox Code Playgroud)
我正在测试一个类名SatzRechner,其中Spring也应该自动装配一些变量.这是我的测试类:
@Component
public class SatzRechner {
@Autowired //@Inject
private Rechner taschenRechner; …Run Code Online (Sandbox Code Playgroud) 我Grid在Vaadin中使用表格进行数据表示.为此,我试图弄清楚以下两个问题:
1.)如何禁用每列标题中的排序功能
2.)如何设置Grid表中一列的颜色
我已经创建了一个结构文件的单元格数组,例如:
>> res2
res2 =
Columns 1 through 7
[1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct] [1x1 struct]
Columns 8 through 10
[1x1 struct] [1x1 struct] [1x1 struct]
>> res2{1}
ans =
nchi005_randchi005: 0.1061
nfdr_randfdr: 0.0011
nlgt_randlgt: 2.9517e-004
nphast_randphast: 0.6660
ndd_rand_dd: 0.0020
ndd_rand_dd_larger: 1
>> res2{1}.nlgt_randlgt
ans =
2.9517e-004
>> res{:}.nlgt_randlgt
??? Bad cell reference operation.
Run Code Online (Sandbox Code Playgroud)
是否有可能立即访问res2-cellarray的所有nlgt_randlgt字段?
我在WebStorm中使用JavaScript和TypeScript,我担心WebStorm的转换行为.每次我在TypeScript文件中进行更改时都会转换.
是否有可能改变这种转换模式,以便仅在我保存时才进行转换?
假设我们有以下枚举:
public enum AnimalImages {
TIGER,BEAR,WOLF;
}
public enum CarImages {
BMW,VW,AUDI;
}
Run Code Online (Sandbox Code Playgroud)
现在我想将这些枚举类保存在 HashMap 中:
Map<String,Enum<?>> enumMap=new HashMap<String,Enum<?>>();
enumMap.put("AnimalImages",???????);
Run Code Online (Sandbox Code Playgroud)
我应该输入什么而不是问号?
例如:
a = [1 1 0 0 1 1 0 1 1 1 0 0];
现在我想只将那些被零除的:
ones = [2 2 3] - 这意味着两个,然后我们有两个零,我们不计算,然后再两个等.
我怎样才能做到这一点?