如果中间的ID为空,则Intellij IDEA会自动将包装链接在一起.这是一个很好的功能.但是,有时您不希望它们被链接,尤其是当您正在为新项目创建新的包结构时.我可能遇到过为某个软件包禁用此功能的设置,但我现在无法找到它.那么,有谁知道如何控制这个功能?非常感谢你.
顺便说一句,如果您需要澄清,我的意思是包链是如下.假设你有这个包结构:
$ tree com
com
??? company
??? project
??? some
??? feature
Run Code Online (Sandbox Code Playgroud)
由于中间文件夹中没有其他内容,因此Intellij IDEA会自动显示它
com.company.project.some.feature
Run Code Online (Sandbox Code Playgroud)
在项目资源管理器中,看起来这些包被链接在一起.
我是Spring的新手.有一件事让我感到困惑的是,有时我会看到带有版本化模式的XML配置文件,但有时会看到非版本化模式.例如,有时我会看到类似的东西
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="base.package"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
有时像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:component-scan base-package="base.package"/>
</beans>
Run Code Online (Sandbox Code Playgroud)
请注意,两个示例中的spring-beans和spring-context模式不同.
所以,我的问题是,你会使用哪种风格?为什么?特别是,版本化架构将来是否会变得不可用,并且当Spring更新架构时,非版本化架构是否会与当前应用程序保持兼容?
一个附带问题是,我在哪里可以找到版本化的弹簧模式列表?
非常感谢!
我的src/test/文件夹包括单元和功能测试.功能测试的类路径有单词cucumber,而单元测试没有.那么,我怎样才能运行单元测试呢?
非常感谢你.
PS:我知道使用"包含"逻辑来选择测试很容易.例如,要仅在我的情况下运行功能测试,我可以简单地使用它
./gradlew test -Dtest.single=cucumber/**/
但是,我不知道如何以简单的方式排除测试.
顺便说一下,我正在使用gradle 1.11.
我的公司有一个环境管理工具,使您能够以编程方式在Java中查找环境中的属性.我想利用这个工具来配置logback.例如,假设我有一个logback.xml,如下所示(特别是文件appender部分):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- console appender -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd/HH:mm:ss.SSS} [%thread] %-5level %logger{20}: %msg%n</pattern>
</encoder>
</appender>
<!-- file appender -->
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${LOG_FILE:-/default/log/file/path</file>
<encoder>
<pattern>%d{yyyy-MM-dd/HH:mm:ss.SSS} [%thread] %-5level %logger{20}: %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
Run Code Online (Sandbox Code Playgroud)
因此,在这种情况下,我想LOG_FILE从环境(或OS,如果你愿意)查找属性,并在logback加载logback.xml之前将其传递给logback,以便它知道值LOG_FILE.那么,我该如何实现呢?顺便说一句,我知道如何以编程方式定义文件追加器,但这不是我想要的.
非常感谢你.
我很好奇AngularJS应用程序通常部署在什么类型的服务器上,而谷歌没有给出满意的答案.特别是,在我看来,AngularJS应用程序只是静态文件的集合,所以将这样的应用程序部署到生产中的vanilla Apache HTTP服务器中是否常见?或者是轻量级的Node.js服务器首选?
非常感谢你.
我喜欢这些Autoscroll to/from source功能.每次导入新项目时,我都会启用它们.但是,每次进行新导入时都必须这样做会很烦人.我用Google搜索,但无法弄清楚如何.那么,你知道如何永久启用它们吗?非常感谢你.
是否可以执行以下操作来修改matplotlib中的导航工具栏?
fig = figure()tbar = fig.get_navigation_toolbar()或更好,只需:tbar = fig.navtbartbar,例如删除/添加/编辑按钮,如下所示:tbar.add_button(<a Button object>);tbar.remove_button(a reference to a button);tbar.edit_button(a reference to a button);fig.canvas.draw()非常感谢你.
假设您有一个原型bean类,如下所示:
@Component
@Scope("prototype")
public class Foobar {
private String foo;
public Foobar( String foo ) {
this.foo = foo;
}
}
Run Code Online (Sandbox Code Playgroud)
那么,是否可以使用@Autowired在另一个类中连接这样的bean,它应该使用非默认构造函数Foobar(String foo)来实例化bean?
update
在上面的示例中,构造函数参数String foo不可从应用程序上下文中获得,而是动态的.因此,对构造函数进行注释,@Autowired然后foo在上下文中指定某处,这似乎不是一个理想的解决方案.
我想要做的是在build.gradle中创建一个将执行主类(使用main方法的类)的任务,但我不知道如何.
我做了一个测试项目来测试如何做到这一点.这是文件结构布局:
testProject/
build.gradle
src/main/groovy/hello/world/HelloWorld.groovy
Run Code Online (Sandbox Code Playgroud)
以下是build.gradle的内容:
apply plugin: 'groovy'
apply plugin: 'maven'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.0.6'
}
task( hello, dependsOn: jar, type: JavaExec ) {
main = 'hello.world.HelloWorld'
}
Run Code Online (Sandbox Code Playgroud)
以下是HelloWorld.groovy的内容:
package hello.world
class HelloWorld {
public static void main(String[] args) {
println "Hello World!"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我从shell获得的:
testProject>$ gradle hello
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:hello
Error: Could not find or load main class hello.world.HelloWorld
:hello FAILED
FAILURE: Build failed with …Run Code Online (Sandbox Code Playgroud) 我在这个<project_root>文件夹下有这些文件:
./build.gradle
./build/libs/vh-1.0-SNAPSHOT.jar
./libs/groovy-all-2.1.7.jar
./src/main/groovy/vh/Main.groovy
Run Code Online (Sandbox Code Playgroud)
在build.gradle文件中,我有这个任务:
task vh( type:Exec ) {
commandLine 'java -cp libs/groovy-all-2.1.7.jar:build/libs/' +
project.name + '-' + version + '.jar vh.Main'
}
Run Code Online (Sandbox Code Playgroud)
该Main.groovy文件很简单:
package vh
class Main {
static void main( String[] args ) {
println 'Hello, World!'
}
}
Run Code Online (Sandbox Code Playgroud)
插入字符串值后,命令行为:
java -cp libs/groovy-all-2.1.7.jar:build/libs/vh-1.0-SNAPSHOT.jar vh.Main
Run Code Online (Sandbox Code Playgroud)
如果我直接从shell运行命令,我得到正确的输出.但是,如果我跑gradle vh,它将失败.那么,我该如何使它工作?非常感谢你.
java ×6
gradle ×3
groovy ×2
spring ×2
angularjs ×1
logback ×1
matplotlib ×1
node.js ×1
python ×1
unit-testing ×1