我有这个代码:
public enum Continent {ASIA, EUROPE}
public class Country {
private String name;
private Continent region;
public Country (String na, Continent reg) {
this.name = na;
this.region = reg;
}
public String getName () {return name;}
public Continent getRegion () {return region;}
@Override
public String toString() {
return "Country [name=" + name + ", region=" + region + "]";
}
}
Run Code Online (Sandbox Code Playgroud)
在主要班级:
public static void main(String[] args) throws IOException {
List<Country> couList = Arrays.asList(
new Country ("Japan", Continent.ASIA),
new Country …Run Code Online (Sandbox Code Playgroud) 我正在学习弹簧框架,我有一个问题.当我创建一个Java/Spring项目时,我应该选择在Spring xml中将哪些类描述为bean?例如:如果我想访问名为Student的DB表,我创建这些类:Student,StudentMapper(实现RowMapper)和StudentJDBCTemplate(DAO).我应该将项目中的每个类描述为Spring Beans吗?选择类将其描述为Spring Bean的标准是什么?
我有这个小程序,它旨在显示指定的Windows文件/文件夹属性对话框info.lpFile:
#include <windows.h>
main() {
SHELLEXECUTEINFO info = {0};
info.cbSize = sizeof(SHELLEXECUTEINFO);
info.lpFile = "C:\\test.txt";
info.nShow = SW_SHOW;
info.fMask = 0x00000000;
info.lpVerb = "properties";
ShellExecuteEx(&info);
}
Run Code Online (Sandbox Code Playgroud)
当我编译并执行它时,我收到以下错误消息:
我正在使用Win7和Mingw gcc编译器.有人知道我的代码有什么问题吗?我错过了什么吗?
我扩展FileSystemView并覆盖了这个类中的每个方法。该模型如下所示:
public class RemoteSystemFilesView extends FileSystemView {
private IDirectoryService directoryService;
public RemoteSystemFilesView(IDirectoryService aDirectoryService){
this.directoryService = aDirectoryService;
}
....
}
Run Code Online (Sandbox Code Playgroud)
该directoryService对象从远程 UNIX 服务器返回目录。然后,我创建JFileChooser.
JFileChooser fc = new JFileChooser(new RemoteSystemFilesView(new DirectoryService()));
int returnVal = fc.showOpenDialog(this);
Run Code Online (Sandbox Code Playgroud)
该对话框正确显示远程目录和文件,但随后我双击显示的文件夹之一,我希望导航到该文件夹,但文件夹路径出现在“文件名”字段中,就是这样。除了root(/)之外,我无法进入任何其他目录。我应该在 中实现其他东西JFileChooser,而不仅仅是在FileSystemView?
最近一直在用Spring boot + spring data jpa + hibernate。我在 spring 事务中遇到了一个问题。这是我的服务类和两个问题:
@Transactional
@Service
class MyService {
@Autowired
private MyRepository myRep;
public void method_A() {
try {
method_C();
.....
method_B();
} catch(Exception e) {}
}
public void method_B() {
Entity e = new Entity();
e.set(...);
myRep.save(e);
}
public void method_C() throws Exception {
....
}
}
Run Code Online (Sandbox Code Playgroud)
1.如果方法method_C()抛出异常,我想捕获它并记录它,事务不会在方法中回滚method_B(),因为异常没有到达Spring框架。那么我应该怎么做才能捕获异常method_C()并同时不失去method_B()回滚方法的能力?
2.考虑新方法method_A()。
public void method_A() {
for(...) {
...
...
method_B();
}
}
Run Code Online (Sandbox Code Playgroud)
我想method_B()在循环中调用。如果在 …
java ×4
spring ×2
c ×1
c++ ×1
hibernate ×1
java-8 ×1
java-stream ×1
jfilechooser ×1
jpa ×1
lambda ×1
spring-data ×1
winapi ×1
windows ×1