环境:
我有那个User实体:
@Entity
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer userId;
@Version
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "VERSION", length = 19)
private Date version;
@Column(nullable = false, length = 20)
private String login;
// Getters and Setters
}
Run Code Online (Sandbox Code Playgroud)
我有一个列出用户的搜索页面,然后我点击一个用户进行编辑(userId在URL中给出).
在编辑表单中,我在服务器上存储该实体的字段,当我保存我的用户时,我这样做:
User user = entityManager.find(User.class, userId)
user.setLogin(form.getLogin());
user.setVersion(form.getVersion());
user.setUserId(form.getUserId());
entityManager.merge(user);
Run Code Online (Sandbox Code Playgroud)
题:
因此,如果我正确理解使用Hibernate的乐观锁定,如果我在浏览器中打开2个选项卡来编辑同一个用户,那么在第一个选项卡上更新登录,然后在第二个选项卡上登录,我应该有一个OptimisticLockException不应该?
实际上,这不是我的应用程序的情况...我验证,form.getVersion()在这两种情况下返回相同的值,即使在第二次更新中,user.version已经由第一次编辑更新.
我错过了什么吗?
该EntityManager生产 …
我正在尝试构建一个基于oracle/database:11.2.0.2-xe(基于 RHEL 的 Oracle Linux)的 Docker 映像,并希望更改此映像中的系统区域设置(使用RUN中的某些命令Dockerfile)。
根据本指南,我应该使用localectl set-locale <MYLOCALE>,但此命令失败并显示Failed to create bus connection: No such file or directory消息。对于需要启动 SystemD 的命令,这是一个已知的 Docker 问题。
无论如何,我尝试启动 SystemD(用作/usr/sbin/init第一个进程以及使用此帮助-v /sys/fs/cgroup:/sys/fs/cgroup:ro -v /run),但随后失败并显示消息。localectl set-localeCould not get properties: Connection timed out
所以我现在试图避免使用 来localectl更改我的系统全局区域设置,我该怎么做?
在一个示例中,我检查了"检索所有嵌入式资源",但现在我的示例报告了一个错误,如果缺少链接资源(来自服务器的HTTP状态404).
我可以告诉我的示例检索嵌入的资源,但忽略丢失或有问题的链接资源吗?(所以我只有在出现真正的功能问题时才能停止装置,而不是在缺少图像时)
与机群一起使用的CoreOS 使得可以构建运行某些docker应用程序的服务.
但有没有办法运行docker服务,它需要在重启之间保持状态,才能持久化?例如,必须存储稍后要共享的某些文件的数据库或服务.
因为据我所知,该服务可以在core-1机器上启动(例如),并且在重启时将随机启动另一个服务.因此,码头工作量可能会丢失.
我正在使用Mocha进行NodeJS测试,当我的源代码抛出错误导致测试失败时(例如" TypeError: Cannot read property 'prop' of null"),显示的堆栈跟踪中的行号是错误的(它们与原始源不匹配)文件,但是要大得多).
1) MyApp should do something:
TypeError: Cannot read property 'prop' of null
at MyApp.<anonymous> (/path/to/my-project/lib/my-project.js:515:93)
at MyApp.build (/path/to/my-project/lib/my-project.js:774:16)
at Context.<anonymous> (/path/to/my-project/test/test.js:62:67)
at Test.Runnable.run (/path/to/my-project/node_modules/mocha/lib/runnable.js:216:15)
at Runner.runTest (/path/to/my-project/node_modules/mocha/lib/runner.js:373:10)
at /path/to/my-project/node_modules/mocha/lib/runner.js:451:12
at next (/path/to/my-project/node_modules/mocha/lib/runner.js:298:14)
at /path/to/my-project/node_modules/mocha/lib/runner.js:308:7
at next (/path/to/my-project/node_modules/mocha/lib/runner.js:246:23)
at Object._onImmediate (/path/to/my-project/node_modules/mocha/lib/runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Run Code Online (Sandbox Code Playgroud)
(这里my-project.js只有279行!)
有没有办法告诉Mocha正确显示它们?
我想在JBoss 7上使用JVisualVM来描述我的webapp.
所以我启动了该工具,并打开运行JBoss的JVM.
我点击"Profiler","设置"和"CPU设置"我把它:
"从类开始分析:":com.mycompany.myapp.action.**
配置新的Runnables
"仅配置文件类:":com.mycompany.*
当我点击"CPU"(配置CPU)时,在JBoss中我得到了:
Profiler Agent: 250 classes cached.
Profiler Agent: Redefining 100 classes at idx 0, out of total 188
Profiler Agent: Redefining 88 classes at idx 100, out of total 188
10:26:05,720 ERROR [stderr] (server-timer1) Exception in thread "server-timer1" java.lang.NoClassDefFoundError: org/netbeans/lib/profiler/server/ProfilerRuntimeCPUFullInstr
10:26:05,721 ERROR [stderr] (server-timer1) at org.jboss.sun.net.httpserver.ServerImpl$ServerTimerTask1.run(ServerImpl.java:895)
10:26:05,722 ERROR [stderr] (server-timer1) at java.util.TimerThread.mainLoop(Timer.java:534)
10:26:05,722 ERROR [stderr] (server-timer1) at java.util.TimerThread.run(Timer.java:484)
Run Code Online (Sandbox Code Playgroud)
通过谷歌搜索,似乎我必须添加jfluid-server.jar JBoss类路径,但是当我使用Eclipse时,jar在我重新启动服务器之前就消失了......
其他人建议使用包含JBoss模块jar的类路径启动VisualVM,但我仍然在JBoss AS中有错误.
是否有配置standalone.xml才能将该jar添加到JBoss 7类路径?
谢谢 !
我想知道RequestScoped上下文当前是否在方法中处于活动状态.
目前,我在做什么:
@Inject private BeanManager beanManager;
public boolean isRequestScopeActive() {
try {
if (beanManager.getContext(RequestScoped.class).isActive()) {
return true;
} else {
return false;
}
} catch (final ContextNotActiveException e) {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我认为,ContextNotActiveException只要了解范围是否有效,我就会有点沉重.
您有没有更好的方法来了解CDI中的上下文的状态(活动与否)?
我定义了@callback这种方式:
/**
* @callback MyClass~Handler
* @param {string} target
* @param {Options} options - Original options
*/
Run Code Online (Sandbox Code Playgroud)
我用它来定义我的类原型:
/**
* @param {string} name - The name
* @param {MyClass~Handler} handler
* @private
*/
MyClass.prototype._builder = function(name, handler) { //...
Run Code Online (Sandbox Code Playgroud)
但是如何告诉JSDoc以下函数与我的定义相同MyClass~Handler(@isacallback在下面的代码中会是这样的)?
/**
* Default handler
* @isacallback {MyClass-Handler}
* @private
*/
MyClass.prototype._defaultHandler = function(target, options) { // ...
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用NW.js运行后台任务(文件系统扫描程序).
在电子,这是可以做到用,并呼吁和主脚本,并在孩子的脚本.child_process.fork(__dirname + '/path_to_js_file')child.on('message', function(param) { ... })child.send(...)process.on('message', function(param) { ... })process.send(...)
在NW.js中,我尝试使用Web Workers但没有任何反应(我的webworker脚本从未执行过).
我还看到有一种解决方法,child_process.fork("path_to_js_file.js", {silent: true, execPath:'/path/to/node'})但这意味着将Node.js捆绑到我未来的应用程序中...
另一个想法?
I'm looking to define /api as the root context for all my @RestControllers and don't want to specify it for each of them.
For instance, I would like to write @RestController("/clients") instead of @RestController("/api/clients") and make my request mappings available at /api/clients but have my static resources (in /main/resources/static) still served at /**.
So, setting server.servlet.contextPath=/api in application.properties is not a solution for my use case because the static resources will be served at /api, which …
docker ×2
javascript ×2
jboss7.x ×2
cdi ×1
coreos ×1
hibernate ×1
java-ee-6 ×1
jboss-weld ×1
jmeter ×1
jpa-2.0 ×1
jsdoc ×1
jvisualvm ×1
locale ×1
mocha.js ×1
node-webkit ×1
node.js ×1
profiling ×1
rhel ×1
spring ×1
spring-boot ×1
spring-mvc ×1
spring-web ×1
systemd ×1