我阅读了IntelliJ的许可,但无法清楚地理解他们的许可条款.
我在公司工作时使用IntelliJ社区版是否合法?或者是否有必要购买Ultimate版本?
今天我偶然发现了一些奇怪的内部(非静态)类行为.
如果我有以下课程......
class B {
String val = "old";
void run(){
val = "new";
System.out.println(val); // outputs: new
new InnerB().printVal(); // outputs: new
}
private class InnerB {
void printVal(){ System.out.println(val); }
}
}
new B().run();
Run Code Online (Sandbox Code Playgroud)
......一切似乎都很清楚.InnerB的实例属于B的实例,因此如果它应该输出val,则打印已经替换的值'new'.
但是如果内部类扩展了外部类,则这不起作用.
class B {
String val = "old";
void run(){
val = "new";
System.out.println(val); // outputs: new
new InnerB().printVal(); // outputs: new
new InheritedB().printVal(); // outputs: old new
}
private class InnerB {
void printVal(){ System.out.println(val); }
}
private class InheritedB extends B{ …
Run Code Online (Sandbox Code Playgroud) 我有一个Spring Boot 1.4.2应用程序.在启动期间使用的一些代码如下所示:
@Component
class SystemTypeDetector{
public enum SystemType{ TYPE_A, TYPE_B, TYPE_C }
public SystemType getSystemType(){ return ... }
}
@Component
public class SomeOtherComponent{
@Autowired
private SystemTypeDetector systemTypeDetector;
@PostConstruct
public void startup(){
switch(systemTypeDetector.getSystemType()){ // <-- NPE here in test
case TYPE_A: ...
case TYPE_B: ...
case TYPE_C: ...
}
}
}
Run Code Online (Sandbox Code Playgroud)
有一个组件可以确定系统类型.在从其他组件启动期间使用此组件.在生产中一切正常.
现在我想使用Spring 1.4的@MockBean添加一些集成测试.
测试看起来像这样:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyWebApplication.class, webEnvironment = RANDOM_PORT)
public class IntegrationTestNrOne {
@MockBean
private SystemTypeDetector systemTypeDetectorMock;
@Before
public void initMock(){
Mockito.when(systemTypeDetectorMock.getSystemType()).thenReturn(TYPE_C);
}
@Test
public void testNrOne(){ …
Run Code Online (Sandbox Code Playgroud) 我正在使用eclipse控制台来运行长而快速的日志.
我找不到让这个控制台像所有其他控制台一样的方法,即如果它向下滚动到最后,那么它应该自动滚动,如果没有,它应该停止滚动.
有没有办法(配置,插件)来实现这一目标?
我现在拥有的是:
task myTask (type : Exec) {
executable "something.sh"
... (a lot of other things)
args "-t"
args ext.target
}
task doIt {
myTask.ext.target = "/tmp/foo"
myTask.execute();
myTask.ext.target = "/tmp/gee"
myTask.execute();
}
Run Code Online (Sandbox Code Playgroud)
有了这个,我想当我开始"doIt"时,我可以用不同的参数运行"myTask".但只是第一次执行脚本,因为gradle会注意一个任务只运行一次.如何重写"myTask"以便我可以多次调用它?没有必要将它作为一项单独的任务.
我们使用Gradle 2.1和java插件.在compileJava期间会发生不同的警告,例如:
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: ../SomeClass.java uses or overrides a deprecated API.
Run Code Online (Sandbox Code Playgroud)
我们知道他们的意思,但不会修复它们(不要问,其他线程:)是否有办法以某种方式避免这些消息?它们会大大扰乱输出:
:project1:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: SomeClass.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
:project1:processResources
:project1:classes
:project1:jar
:project2:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
:project2:processResources
:project2:classes
:project2:jar
:project2:war
Run Code Online (Sandbox Code Playgroud)
例如,在compileJava期间重定向stderr流是不是可能,以便我们可以发出警告?或者还有另一种方式吗?
在启动时,我们需要获取正在运行的应用程序的服务器地址和http端口.到现在为止我们这样做了:
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName socketBindingMBean = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http");
String host = (String) mBeanServer.getAttribute(socketBindingMBean, "boundAddress"),
Integer port = (Integer) mBeanServer.getAttribute(socketBindingMBean, "boundPort"));
Run Code Online (Sandbox Code Playgroud)
一切都很好但是从jBoss 7.1.1.Final迁移到7.1.3.Final后我们遇到了MBean未在服务器启动时定义的问题.这意味着如果我在已经运行的 jboss服务器上部署应用程序,一切都很好,但如果我启动服务器并且在服务器启动期间加载了应用程序MBean不在那里.
我不知道为什么,但我觉得jBoss确保在大多数MBean之前启动/加载应用程序.我看了一眼,发现在申请后加载了Mbeans:
所以,
如何在Intellij上禁用空格键的自动完成
问题:我总是键入"... =".在"="之后提到空格.问题是自动完成弹出窗口在插入"="后立即出现,因此下一个键始终应用第一个提议.
IntelliJ 2016.1.2
我在gradle项目中添加了一个任务:
task deploy() {
dependsOn "build"
// excludeTask "test" <-- something like this
doFirst {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
现在build
任务总是在deploy
任务之前运行.这很好,因为构建任务包含许多步骤.现在我想明确禁用其中一个包含的任务.
通常我从命令行禁用它
gradle deploy -x test
Run Code Online (Sandbox Code Playgroud)
如何以test
编程方式排除任务?
我们与一位客户存在某种问题,该客户认为我们发送的 XML 文件中的两个版本的空标记之间存在语义差异(纯 XML 没有 HTML ..)。
他们期望:
<our-xml>
<some-tag></some-tag>
</our-xml>
Run Code Online (Sandbox Code Playgroud)
我们发送:
<our-xml>
<some-tag />
</our-xml>
Run Code Online (Sandbox Code Playgroud)
我们认为这是完全相同的,但我们无法真正用事实证明这些论点。我们发现的唯一内容是在https://www.w3.org/TR/REC-xml/#sec-starttags中说的
空元素标签可用于任何没有内容的元素。
是否有任何讨论或更明确的论文可供我们依赖,或者我们错了?