我已经设置了git的配置,以便'git config --list'给出以下内容:
core.editor=vim
core.whitespace=trailing-space,space-before-tab,indent-with-non-tab
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
Run Code Online (Sandbox Code Playgroud)
但是,当我想提交文件whit尾随空格或其他空白问题时,它永远不会抱怨.不知道我能做什么.
我正在开发我的第一个Java Web应用程序(Spring/Hibernate/Freemarker),我唯一关心的是开发速度.
我以前用PHP开发,只需重新加载浏览器即可查看结果.使用Java,我需要始终在IDE中单击"更新资源",以查看对模板所做的更改.在我看来,这种开发方式效率非常低,因为重新部署需要几秒钟.
此外,我不是准备模板的人 - 它只是一个图形人,他也想测试它们.他是否需要拥有自己的应用程序服务器并继续重新部署应用程序,还是需要更多"PHP"方式来"重新加载"页面?
我正在尝试实现一个表示XML树的类,如下所示:
public class XML<T extends XML<T>> {
private final List<MarkupLanguage> nodeList = new ArrayList<>();
private final Map<String, String> attributeList = new HashMap<>();
public T attr(final String key, final String value) {
if (value != null) {
this.attributeList.put(key, value);
}
return (T) this;
}
public T appendTo(final T node) {
node.add(this);
return (T) this;
}
...
}
Run Code Online (Sandbox Code Playgroud)
我的问题是键入这些条款 - 我正在取消选中"for return(T)this";
当我尝试单独使用XML类时:
final XML url = new XML("url");
new XML("loc")
.add("http://goout.cz")
.appendTo(url);
Run Code Online (Sandbox Code Playgroud)
我正进入(状态:
Unchecked cast to call appendTo(T) as a member …Run Code Online (Sandbox Code Playgroud) 我试图用简单的构造函数实现这个枚举,如下所示:
enum class WithGraphicKind(val innerClass: Class<*>) {
CONTACT(Contact::class.java), SALE(Sale::class.java);
}
Run Code Online (Sandbox Code Playgroud)
由于两者Contact和Sale类都实现了一个公共接口WithGraphics,我想将构造函数键入innerClass: Class<WithGraphics>,但是这不起作用.我也试过Class<* : WithGraphics>和其他人一样,但没有任何作用.我也没有在官方文档中找到任何提示:https://kotlinlang.org/docs/reference/generics.html
考虑这个函数,我们尝试在以下结果中添加一个元素toMap(): MutableMap<String, Any>:
fun add(key: String, value: Any): MutableMap<String, Any> {
val map = asMap()
map.put(key, value)
return map
}
Run Code Online (Sandbox Code Playgroud)
这很简单,但我想知道是否可以简化为"单线程"?就像是:
fun add(key: String, value: Any): MutableMap<String, Any>
= asMap().magicPut(key, value)
Run Code Online (Sandbox Code Playgroud)
编辑:显然我不够清楚:asMap()是一个用户定义的函数,返回带有一些条目的MutableMap.该add方法应该添加到此已存在的地图中.
EDIT2:根据意见,我改名toMap()到asMap().
我试图用MySQL替换我的应用程序中的PostgreSQL.我认为替换<properties>in persistence.xml文件应该足够了:
PostgreSQL的:
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost/postgres"/>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.show_sql" value="true"/>
Run Code Online (Sandbox Code Playgroud)
MySQL的:
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hiberante.connection.url" value="jdbc:mysql://localhost:3306/GoOut2"/>
<property name="hibernate.connection.username" value=""/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
Run Code Online (Sandbox Code Playgroud)
但是有了这个替代品,我得到了
java.lang.UnsupportedOperationException: The application must supply JDBC connections
Run Code Online (Sandbox Code Playgroud)
我不确定我做错了什么,我只是希望更换是直截了当的.在PostgreSQL中,一切正常.
Persistence.xml:https://gist.github.com/2252443
applicationContext.xml:https://gist.github.com/2252463
例外:https://gist.github.com/2252487
谢谢!
编辑:我故意从给定的代码中删除用户名和密码.
假设我有一个Java列表,如下所示:
[
[A, AA, 10],
[A, AB, 11],
[B, BA, 20],
[A, AA, 12],
]
Run Code Online (Sandbox Code Playgroud)
我想处理每一行来创建地图的地图,以便我可以解决每行中的最后一个值,如下所示:
{
A: {
AA: [10, 12]
AB: [11]
},
B: {
BA: [20]
}
}
Run Code Online (Sandbox Code Playgroud)
通过这种方式我可以做如下调用:
for (int i : map.get("A").get("AA")) { ... }
Run Code Online (Sandbox Code Playgroud)
当然,我可以迭代列表并手动创建地图.然而,这是一段非常丑陋的代码,很难将它概括为3,4,5,...,n列.
是否有一些聪明的方式来处理这些列表?某种图书馆或其他我没想过的东西?
我有一个简单的表格,我想处理点击元素:
<div class="row"
v-bind:class="{selected: isSelected}"
v-for="scanner in scanners"
v-on:click="scannerFilter">
{{scanner.id}} ...
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
new Vue({
el: "#checkInScannersHolder",
data: {
scanners: [],
loading: true
},
methods: {
scannerFilter: function(event) {
// isSelected for current row
this.isSelected = true;
// unselecting all other rows?
}
}
});
Run Code Online (Sandbox Code Playgroud)
单击并选择某行时,我的问题是取消选中所有其他行.
此外,我有兴趣知道,它可以访问scannervia回调函数的一些变量而不是使用this我可能需要访问当前上下文.
考虑这个简单的类:
class Foo {
fun a(x: Int) = ...
fun b(x: Int) = ...
fun c(x: Int, y: Int) = ...
}
Run Code Online (Sandbox Code Playgroud)
任何类函数都可能抛出异常。在这种情况下,我想记录该方法的输入参数。我可以在每个方法中手动编写 try-catch 块 - 但它们会使代码变得丑陋和重复。或者 - 我可以尝试找到一些不错的解决方案来保持代码整洁。
有没有办法自动生成 try-catch 块并定义它应该做什么?就像是:
class Foo {
@WithTryCatch fun a(x: Int) = ...
@WithTryCatch fun b(x: Int) = ...
@WithTryCatch fun c(x: Int, y: Int) = ...
fun executeOnCatch() {
log.fatal(...)
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用一个简单的函数来扩展 Enum 伴随对象,如下所示:
fun Enum.Companion.myFun() = 1
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试在 Enum 上调用它时State,Kotlin 不知道它。
State.myFun()
Run Code Online (Sandbox Code Playgroud)
我可以看到它适用于Enum.myFun(),但这不是我需要的。
java ×4
kotlin ×4
dictionary ×1
generics ×1
git ×1
hibernate ×1
jpa ×1
list ×1
mysql ×1
postgresql ×1
templates ×1
vue.js ×1
whitespace ×1