我试图找出我正在维护,使用的应用程序的数据库表的数量.我在appContext.xml中有这个
<context:component-scan base-package="com.foo, com.bar" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
<context:include-filter type="annotation" expression="org.springframework.stereotype.Component" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
....
<jpa:repositories base-package="com.foo.abc, com.bar.def" />
Run Code Online (Sandbox Code Playgroud)
还有其他与该项目相关的子项目,@Entity并且@Repository已经广泛使用.我想如果我能够以某种方式打开Spring的调试,它将列出所有类名,并且当它基于基础包扫描它们时,我应该能够找到所有jpa存储库.如何打开弹簧调试以吐出这些信息?
这就是我在log4j.properties中的内容:
log4j.rootLogger=error, file
log4j.category.org.hibernate=debug, hb
log4j.category.org.springframework=debug, spring
Run Code Online (Sandbox Code Playgroud) 为了测试这一点,我迅速提出了以下内容:
public class Test {
public static void main(String[] args) {
try {
Employee e = new Employee();
e.setName("A");
Employee y = new Employee();
// y=e;
BeanUtils.copyProperties(y, e);
e.setName("B");
System.out.println(y.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
}
class Employee{
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
这应该打印A而不是打印null。这里出了什么问题?我如何才能真正将属性从一个对象复制到另一个对象(而不是让它们指向相同的值),并且BeanUtils.copyProperties 是否首先 创建了深层副本?
我维护一个旧的代码库.其中一个类有这个方法:
someMethod(Param1 a, Param2 b, Param3 c, Param4 d){...};
Run Code Online (Sandbox Code Playgroud)
此方法广泛用于许多java类中.像这样:
foo.someMethod(valueA, null, valueC, null);
Run Code Online (Sandbox Code Playgroud)
如何在我的代码库中找到哪个java类使用此方法,其中最后一个参数未作为null传递?
我正在尝试为此查询制定方法名称:
@Query("from Employees where department = ?1 and (fullTime = true or contractor = true or subContractor = true)")
Run Code Online (Sandbox Code Playgroud)
我认为这种方法可以解决这个问题,但是它会在一个部门和全部时间进行
public List<Employees> findByDepartmentAndfullTimeTrueOrContractorTrueOrSubContractorTrue(String dept);
Run Code Online (Sandbox Code Playgroud)
这是一个相关的问题:Spring JPA Data"OR"查询但在2012年被问到.有没有办法实现这一点而不必使用@Query?
我将firstname复制到lastname字段.这适用于页面上的新名称.但是,在输入几个名称后,浏览器会显示名称的历史记录,如果有任何预填充名称或选择的旧名称,则不会触发此功能.如何将lastName更新为firstName已更改为的内容?
$(document).ready(function() {
$("#FName").change(function() {
$("#LName").val($(this).val());
});
Run Code Online (Sandbox Code Playgroud)
(例如,当你第三次进入J时,你从John,Jack开始,它将John和Jack显示为可用名称.选择预填充值时不会触发Jquery更改)
FF为此打开了一个错误:https://bugzilla.mozilla.org/show_bug.cgi? id = 87943
我正在尝试使用java 8 中新的\R正则表达式匹配器。但是,对于以下代码:
public static void main(String[] args)
{
String s = "This is \r\n a String with \n Different Newlines \r and other things.";
System.out.println(s);
System.out.println(Pattern.matches("\\R", s));
if (Pattern.matches("\\R", s)) // <-- is always false
{
System.out.println("Matched");
}
System.out.println(s.replaceAll("\\R", "<br/>")); //This is a String with <br/> Different Newlines <br/> and other things.
}
Run Code Online (Sandbox Code Playgroud)
将Pattern.matches始终返回false,其中作为replaceAll方法似乎找到了比赛和做什么,我想它。如何使 Pattern.matches 工作?
我也试过很长的路,但仍然无法让它工作:
Pattern p = Pattern.compile("\\R");
Matcher m = p.matcher(s);
boolean b = m.matches();
System.out.println(b);
Run Code Online (Sandbox Code Playgroud) 我该如何去更新已检出的分支,并使用已更新的分支(在本地分支从dev分支出来之后,合并了一些拉取请求)develop分支?目前,如果我branch_1正在进行未提交/已提交/已推送的更改,则可以执行
git checkout develop
git pull
git checkout branch_1
git merge develop
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以减少我实现的目标?
此循环插入员工ID,如1,2,4,... 30.
for(int i=01;i<31;i++){
Employee e = new Employee();
e.setEmpId(i);
aList.add(e);
}
Run Code Online (Sandbox Code Playgroud)
但是,我需要01,02,03等格式的ID.有一种简单的方法可以达到这个目的吗?
我希望将一个L1 的元素放在另一个L2的前面,但我找不到开箱即用的方式来做到这一点。我不想创建第三个ArrayList,因为L2是视图层中正在使用的List,所以我不想乱搞。据我所知,也没有这样的实用程序方法。java.util.ArrayListjava.util.ArrayListjava.util.Collectionsorg.apache.commons.collections.CollectionUtils
如何最好使用现有API有效地将ArrayList附加到另一个ArrayList?对于Java 7环境。
PS:addAll追加,我想先。