我正在使用Oracle 10g和SqlDeveloper.当我执行以下代码时,它说
"功能wafadar编译警告:执行完成并发出警告"
create or replace function wafadar
return varchar2(10)
is
cursor c1 is
SELECT employee_id,first_name FROM employees where department_id=50 ;
begin
for i in c1
loop
dbms_output.put_line(i.first_name);
end loop;
return 'hello';
end;
Run Code Online (Sandbox Code Playgroud)
最后显示的错误也没有显示警告.为什么会有警告?
假设一个映射包含整数键,并且一个字符串列表作为其值.然后,我不能这样做:
for (Map.Entry<Integer, List<String>> entry : map.entrySet()){
for (String string : entry.getValue()){
if (string.startsWith("a")){
entry.getValue().remove(string);
}
}
}
Run Code Online (Sandbox Code Playgroud)
它抛出ConcurrentModificationException.但如果我做以下事情:
for (Map.Entry<Integer, List<String>> entry : map.entrySet()){
entry.setValue(new ArrayList<String>());
}
Run Code Online (Sandbox Code Playgroud)
这非常有效.我们现在不是在修改底层地图吗?
我不想加载整个Spring Boot配置来对我的DAO图层进行单元测试,因此创建了一个嵌套的配置类来抑制默认配置。但是,当我尝试指定要在测试之前运行的SQL脚本时,它找不到它们。
这是代码:
package com.test.customer.controller;
..
@RunWith(SpringRunner.class)
@JdbcTest
@Sql({"data.sql"})
public class InterviewInformationControllerTest {
@Configuration
static class TestConfiguration{
}
@Test
public void testCustomer() {
// code
}
}
I get the error: Cannot read SQL script from class path resource [com/test/customer/controller/data.sql]; nested exception is java.io.FileNotFoundException: class path resource [com/test/customer/controller/data.sql] cannot be opened because it does not exist
Run Code Online (Sandbox Code Playgroud)
我尝试将文件放置在src/main/resources(不喜欢)和src/test/resources(我喜欢)这两个位置
注意:我正在通过Eclipse在Eclipse中运行单元测试Run as -> JUnit test。
编辑:将static关键字添加到配置类
在以下代码中,行为是否未定义?
#include<stdio.h>
int main()
{
printf(7+"%c","sundaram");
}
Run Code Online (Sandbox Code Playgroud)
它印刷"aram".无法理解如何.
<select id="name" >
<option value="" selected="selected">Please select</option>
<option value="Alex">Alex</option>
<option value="Greg">Greg</option>
</select>
Run Code Online (Sandbox Code Playgroud)
如果我们试图通过附加一个选项
$('<option>Hi</option>').appendTo($('#name'))
然后,该选项将添加到选择框中,如预期的那样.但是,如果我们执行以下操作:
var a = $('#name option')[1];
$(a).appendTo($('#name'));
Run Code Online (Sandbox Code Playgroud)
然后,该选项不会附加到选项.相反,"亚历克斯"现在到了最后.我的问题是,最后应该附加另一个"Alex"选项,原来的"Alex"保留在原位
我有以下枚举:
public enum Rank{
FIRST,
SECOND
}
Run Code Online (Sandbox Code Playgroud)
每当toString()在枚举上调用一个函数(或在字符串文字中使用它)时,我都希望返回FIRST_RANK(而不是字符串' FIRST ',默认情况下).如果我重写toString()函数,如:
@Override
public String toString(){
return this.toString() + "_RANK";
}
Run Code Online (Sandbox Code Playgroud)
但这显然会导致递归.问题是我需要使用toString()枚举的默认实现,并且没有toString()我可以调用的超类枚举.
public abstract class A{
}
class B{
@Autowired
A a;
}
Run Code Online (Sandbox Code Playgroud)
当我可以将接口插入 Spring 时,为什么这似乎不起作用?难道它不应该找到一个扩展抽象类 A 的具体类,然后将其连接到类 B 中,就像接口一样?
我想在不涉及主要 Spring 配置的情况下JUnit对我的层运行测试。DAO因此,我声明了一个用 注释的内部类,@Configuration以便它将覆盖用 注释的主应用程序类的配置@SpringBootApplication。
这是代码:
@RunWith(SpringRunner.class)
@JdbcTest
public class InterviewInformationControllerTest {
@Configuration
class TestConfiguration{
@Bean
public InterviewInformationDao getInterviewInformationDao(){
return new InterviewInformationDaoImpl();
}
}
@Autowired
private InterviewInformationDao dao;
@Test
public void testCustomer() {
List<Customer> customers = dao.getCustomers();
assertNotNull(customers);
assertTrue(customers.size() == 4);
}
}
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
Parameter 0 of constructor in com.test.home.controller.InterviewInformationControllerTest$TestConfiguration required a bean of type 'com.test.home.controller.InterviewInformationControllerTest' that could not be found.
Run Code Online (Sandbox Code Playgroud) java ×5
spring ×3
junit ×2
spring-boot ×2
c ×1
concurrency ×1
enums ×1
html ×1
javascript ×1
jquery ×1
loops ×1
map ×1
overriding ×1
plsql ×1
printf ×1