我有一个Spring配置文件spring-idol.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
....
</beans>
Run Code Online (Sandbox Code Playgroud)
我想为AOP添加名称空间声明
<?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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
...
</beans>
Run Code Online (Sandbox Code Playgroud)
有没有办法使用Spring IDE?现在,我能想到的唯一方法是使用aop命名空间声明创建一个新的spring配置文件,然后将声明从那里复制并粘贴到我的bean所在的配置文件中.
我正在重构一个超过500行的方法(不要问我为什么)
该方法基本上从数据库中查询地图列表,并且对于列表中的每个地图进行一些计算并将该计算的值添加到地图中.然而,有太多的计算和完成,代码已经达到500多行!
这是一个示例预览:
public List<Hashmap> getProductData(...) {
List<Hashmap> products = productsDao.getProductData(...);
for (Product product: products) {
product.put("Volume",new BigDecimanl(product.get("Height")*
product.get("Width")*product.get("Length"));
//over 10 more lines like the one above
if (some condition here) {
//20 lines worth of product.put(..,..)
} else {
//20 lines worth of product.put(..,..)
}
//3 more if-else statements like the one above
try {
product.put(..,..)
} catch (Exception e) {
product.put("",..)
}
//over 8 more try-catches of the form above
}
Run Code Online (Sandbox Code Playgroud)
关于如何重构这个的任何想法?
我有一个函数试图循环结构中的2D数组:
typedef struct node
{
int grid[3][3];
} Node;
void someFunction(Node *node) {
int grid[3][3] = node->grid;
//loop through
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译它时,我得到了一个
mp.c:42:错误:初始化程序无效
如何在Eclipse中运行PHP网页?我正在使用PDT.
我在学习Java EE时能够做到这一点.我刚刚运行,然后Eclipse的内置浏览器显示,你已经可以运行该网站.
现在我可以通过将我的PHP文件放在Apache服务的文件夹中然后打开浏览器并转到我创建的php文件来完成此操作.
每当我从svn更新我们项目的代码时,我必须设置我再次导入的库的构建路径,因为最后一个提交的人具有与我不同的类路径.
在从SVN更新后,Eclipse中有没有办法自动放入导入的库?我听说过构建文件(Ant,Maven),但我真的不确定我是否正在寻找合适的东西.
我们的服务器最近一直在下降很多,我的任务是改善一组被认定为罪魁祸首的类的内存使用.
我有初始化对象实例的代码,如下所示:
布尔var1; 布尔var2; ...布尔var100;
void setup() {
var1 = map.hasFlag("var1");
var2 = map.hasFlag("var2);
.
.
.
if (map.hasFlag("some flag") {
doSomething();
}
if (var1) {
increment something
}
if (var2) {
increment something
}
}
Run Code Online (Sandbox Code Playgroud)
设置代码大约需要1300行.我的问题是,在使用太多实例变量方面,这种方法是否有可能更有效.
顺便说一下,实例变量用在"main"方法handleRow()中,例如:
handleRow(){
if (var1) {
doSomething();
}
.
.
.
if (var100) {
doSomething();
}
}
Run Code Online (Sandbox Code Playgroud)
我想的一个解决方案是通过删除setup方法中的实例变量来更改实现,并在需要时直接从地图中调用它:
handleRow(){
if (map.hasFlag("var1") {
doSomething();
}
.
.
.
if (map.hasFlag("var100") {
doSomething();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我正在考虑的一个解决方案,但我想听听社区的意见.:)