Eclipse不断给我错误:
The value for annotation attribute Min.value must be a constant expression
Run Code Online (Sandbox Code Playgroud)
但我绝对是给注释一个常数.
private static final int MIN_YEAR = Calendar.getInstance().get(Calendar.YEAR) - 1;
@Min(MIN_YEAR)
Run Code Online (Sandbox Code Playgroud)
如果我改变它
private static final int MIN_YEAR = 2013;
Run Code Online (Sandbox Code Playgroud)
它非常开心,但我不应该这样做.有没有人知道为什么或如何将我的MIN_YEAR常量视为常量,如果它是用一个计算表达式而不是普通数字声明的?
我正在eclipse中开展一个javascript项目.静态html和javascript文件需要访问我的服务的restful端点,所以我把这些端点放在java项目中,所以我可以访问它们而不会出现跨域问题.
但是,突然间,如果我尝试将更改保存到我的html文件中,除非我停止运行java应用程序,否则我无法做到.
事件的顺序是这样的:
Run java web app with Jetty
Can save changes to html file.
Open html file in chrome with url: http://127.0.0.1:8901/myapp/myapp-admin.html
Cannot save changes to html file.
Close chrome.
Still can't save changes.
Stop jetty running in eclipse.
Can save changes.
Run Code Online (Sandbox Code Playgroud)
当我尝试保存它时出现以下错误:
Save could not be completed. Try File > Save As... if the problem persists.
Reason:
Could not write file:
C:\{path to file}\myapp-admin.html
(The requested operation cannot be performed on a file with a user-mapped section open) …Run Code Online (Sandbox Code Playgroud) 所以我正在编写一个单元测试来测试一些多线程,我想知道这段代码是否能保证按照我的预期工作.
fun testNumbers() {
var firstNumber: Int? = null
var secondNumber: Int? = null
val startLatch = CountDownLatch(2)
val exec = Executors.newFixedThreadPool(2)
exec.submit({
startLatch.countDown()
startLatch.await()
firstNumber = StuffDoer.makeNumber()
})
exec.submit({
startLatch.countDown()
startLatch.await()
secondNumber = StuffDoer().makeNumber()
})
while (firstNumber == null || secondNumber == null) {
Thread.sleep(1)
}
}
Run Code Online (Sandbox Code Playgroud)
具体来说,这种方法是否可以保证完成?firstNumber并且secondNumber不是volatile这样意味着exec运行测试的线程可能永远不会看到线程中那些值设置的结果?你不能将volatile应用于局部变量,所以实际上对我来说,如果可能有必要,你不能使函数局部变量变得不稳定.
(我将Java添加为标记,因为大概在Java中基本问题是相同的.)
我遇到Intellij无法找到我的tsconfig.json文件的问题.我的文件夹结构是这样的:
/ui
/src (all typescript files in here)
tsconfig.json
Run Code Online (Sandbox Code Playgroud)
在我的tsconfig.json档案中,我有:
{
"compilerOptions": {
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es7", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": false,
"suppressImplicitAnyIndexErrors": true,
"experimentalDecorators": true,
"types": [
"node",
"webpack-env"
]
},
"exclude": [
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest"
],
"include": [
"src/**/*"
]
}
Run Code Online (Sandbox Code Playgroud)
Intellij知道如何使用命令+ B(转到声明)从"src"导航到我的src文件夹.如果我关闭Intellij并重新打开它并点击Typescript中的"全部编译"它甚至可以编译所有内容到Javascript.然后它报告错误Error: Cannot find parent 'tsconfig.json'.有时,它仍然会编译成Typescript,但从来没有点击"全部编译".
这是一个Intellij错误吗?看起来像是一个.我刚刚升级到Intellij 2017.3,虽然我不确定我以前是否遇到过这个问题. …
我有一个非常简单的查询,正在一个大表(500k 行)上运行来对结果进行分页。
最初我使用的是这个查询,它非常快:
select * from deck
order by
deck.sas_rating desc
limit 10
Run Code Online (Sandbox Code Playgroud)
其解释分析显示执行时间为 0.2ms。凉爽的。
但是该sas_rating列具有重复的整数值,并且我意识到在分页结果时(使用其他页面的偏移量)我得到了重复的结果。没问题,将主键添加为辅助排序依据。但表现却很糟糕。
select * from deck
order by
deck.sas_rating desc,
deck.id asc
limit 10
Run Code Online (Sandbox Code Playgroud)
需要 685 毫秒,并进行以下解释分析:
Limit (cost=164593.15..164593.17 rows=10 width=1496) (actual time=685.138..685.139 rows=10 loops=1)
-> Sort (cost=164593.15..165866.51 rows=509343 width=1496) (actual time=685.137..685.137 rows=10 loops=1)
Sort Key: sas_rating DESC, id
Sort Method: top-N heapsort Memory: 59kB
-> Seq Scan on deck (cost=0.00..153586.43 rows=509343 width=1496) (actual time=0.009..593.444 rows=509355 loops=1)
Planning time: 0.143 ms
Execution …Run Code Online (Sandbox Code Playgroud) 在我的 maven java webapp 构建中,我有以下插件:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是我使用的 Jetty 版本有那个烦人的“空身份服务”,所以我想升级我使用的版本,但我想不出任何好方法来确定哪个版本的 jetty 是最好的让我跑。
我找到了这个 Jetty 文档,它显示了一些信息,但只涉及大版本号,如 6、7、8 和 9。我使用的是 javax.servlet 3.0.1,所以我想我想要码头 8 或 9 .
这个 Jetty 文档似乎告诉我如何找出要使用的各个版本,但我并不完全明白。从那看来,也许我应该使用 9.0.0.RC0?
在jetty的maven repo 页面上,我可以看到很多版本,但最新的版本8 是我使用的带有漏洞的身份服务的版本,而9 都是“里程碑”,我认为这意味着它们是比较不靠谱?我真的不知道“里程碑”是什么意思。
我很感激一些指导或建议!
我试图传递一个迭代器作为Spring Data中方法的参数,但是eclipse告诉我Java正在尝试调用相同方法的普通实体重载.
public void persistLandTiles(List<LandTile> tilesToPersist) {
landTileRepo.save(tilesToPersist.iterator());
}
Run Code Online (Sandbox Code Playgroud)
错误:
Bound mismatch: The generic method save(U) of type CRUDRepository<T> is not applicable
for the arguments (Iterator<LandTile>). The inferred type Iterator<LandTile> is not a
valid substitute for the bounded parameter <U extends LandTile>
Run Code Online (Sandbox Code Playgroud)
和调用的接口方法:
@NoRepositoryBean
public interface CRUDRepository<T> extends PagingAndSortingRepository<T, Long> {
/**
* persists an entity by forwarding to entity.persist()
* @param entity to be persisted
* @return the saved entity (being the same reference as the parameter)
*/
@Transactional …Run Code Online (Sandbox Code Playgroud) 我想在dart中声明一个字段,并且仅覆盖getter的功能,但是我不确定如何/是否可行。
class Pony {
String ponyGreeting;
String ponyName;
Pony(this.ponyGreeting, this.ponyName);
String get ponyGreeting => "$ponyGreeting I'm $ponyName!";
}
Run Code Online (Sandbox Code Playgroud)
但是,这会导致错误,因为我已经定义了“ ponyGreeting”。我不能仅仅摆脱ponyGreeting字段,因为我想使用构造函数来设置它,如果我创建了一个setter,我将不得不在某个地方设置该值,而我实际上并不需要多余的属性。
我用Angular.js编写了一个表单,要求在提交之前填写一个字段.验证工作正常(当我提交表单时,该字段显示验证错误)但表单似乎仍然执行其ng-click操作.
尽管有验证错误,是否应该提交角形式?如果存在验证错误,阻止其提交的最佳方法是什么?
这是有问题的表格:
<form role="form">
<div class="form-group">
<label>Book Id</label><br>
<input ng-model="bookToSend.bookId" class="form-control" maxlength="40" required type="text">
</div>
<button type="submit" ng-click="sendBookUpdate(BookToSend)">Send Book Update</button>
</form>
Run Code Online (Sandbox Code Playgroud) 我们在GWT中有一个上传表单,用于上传文件.它在上传文件时工作正常,但如果我们连续上传两个以上的文件,然后点击浏览器后退按钮,就会发生奇怪的事情.页面消失,最终重新加载,然后冻结.在重新加载之前,没有按钮可被点击.这种情况发生在Chrome 39中,但不是我尝试过的其他浏览器(和旧版本的Firefox).
为什么表单面板会提交类似的内容?我该如何解决?我似乎找不到从历史记录中删除表单提交的方法,或者是一种不使用GWT的FormPanel和FileUpload上传文件的简单方法.我不能只是在每次上传文件后重新加载页面,因为刷新非常慢.
这是创建面板相关部分的代码:
FormPanel uploadForm = new FormPanel();
uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
uploadForm.setMethod(FormPanel.METHOD_POST);
uploadForm.setAction(servletPath + destinationUrl);
FileUpload fileInput = new FileUpload();
uploadForm.add(fileInput.asWidget());
Run Code Online (Sandbox Code Playgroud)
当用户点击上传所选文件时,我们使用:
uploadForm.submit();
Run Code Online (Sandbox Code Playgroud)
该GWTUploadProject是不是一个解决方案,因为它的工作原理可以说是雪上加霜.如果您尝试在上传示例页面后单击后退,则会显示以前上传图像的额外缩略图!
java ×5
jetty ×2
angularjs ×1
dart ×1
eclipse ×1
file-upload ×1
forms ×1
gwt ×1
html ×1
javascript ×1
kotlin ×1
maven ×1
postgresql ×1
spring ×1
spring-data ×1
sql ×1
tsconfig ×1
typescript ×1
validation ×1
web.xml ×1