小编ber*_*rdt的帖子

在application.yml中设置root日志记录级别

我在Spring Boot(1.3 M1)中使用了application.properties并开始将其转换为yaml文件,因为它变得越来越复杂.

但我有问题将其翻译成yaml:

logging.level.*=WARN
logging.level.com.filenet.wcm=ERROR
logging.level.de.mycompany=DEBUG
Run Code Online (Sandbox Code Playgroud)

最后两行很容易翻译成:

logging:
    level:
        com.filenet.wcm: ERROR
        de.mycompany: DEBUG
Run Code Online (Sandbox Code Playgroud)

但是如何添加根日志记录级别的值?这两种方法都失败了:

方法1失败:

logging:
    level: WARN
        com.filenet.wcm: ERROR
        de.mycompany: DEBUG    
Run Code Online (Sandbox Code Playgroud)

方法2失败:

logging:
    level: 
        star: WARN
        com.filenet.wcm: ERROR
        de.mycompany: DEBUG    
Run Code Online (Sandbox Code Playgroud)

我阅读了文档,搜索了stackoverflow和googled,但没有找到有效语法的示例.

java logging yaml spring-boot

57
推荐指数
3
解决办法
5万
查看次数

Java - 格式化双倍值作为美元金额

我需要将双"amt"格式化为美元金额println("$"+美元+"."+美分),以便小数点后有两位数.

这样做的最佳方法是什么?

if (payOrCharge <= 1)
{
    System.out.println("Please enter the payment amount:");
    double amt = keyboard.nextDouble();
    cOne.makePayment(amt);
    System.out.println("-------------------------------");
    System.out.println("The original balance is " + cardBalance + ".");
    System.out.println("You made a payment in the amount of " + amt + ".");
    System.out.println("The new balance is " + (cardBalance - amt) + ".");
}
else if (payOrCharge >= 2)
{
    System.out.println("Please enter the charged amount:");
    double amt = keyboard.nextDouble();
    cOne.addCharge(amt);
    System.out.println("-------------------------------");
    System.out.println("The original balance is $" + cardBalance + ".");
    System.out.println("You added …
Run Code Online (Sandbox Code Playgroud)

java double formatting

29
推荐指数
4
解决办法
8万
查看次数

Maven build [警告]我们有一个重复的类

有谁知道我的maven构建发生了什么?我收到了很多重复的警告.

[WARNING] We have a duplicate org/apache/commons/logging/impl/LogFactoryImpl$1.class in /home/shengjie/.m2/repository/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar
[WARNING] We have a duplicate org/apache/commons/logging/impl/LogFactoryImpl.class in /home/shengjie/.m2/repository/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar
[WARNING] We have a duplicate org/apache/commons/logging/impl/NoOpLog.class in /home/shengjie/.m2/repository/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar
[WARNING] We have a duplicate org/apache/commons/logging/impl/SimpleLog$1.class in /home/shengjie/.m2/repository/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar
[WARNING] We have a duplicate org/apache/commons/logging/impl/SimpleLog.class in /home/shengjie/.m2/repository/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar
[WARNING] We have a duplicate org/apache/commons/logging/impl/Jdk14Logger.class in /home/shengjie/.m2/repository/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar
Run Code Online (Sandbox Code Playgroud)

我查看了我当地的m2 repo,我在commons-logging-api jar,LogFactoryImpl.class和LogFactoryImpl $ 1.class中有两个类.与警告中提到的所有类相同.

有一点需要提一下,我在我的pom.xml中使用了shade插件.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.4</version>
            <configuration>
                <createDependencyReducedPom>true</createDependencyReducedPom>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers> …
Run Code Online (Sandbox Code Playgroud)

build maven maven-shade-plugin apache-commons-logging

28
推荐指数
3
解决办法
3万
查看次数

添加For循环可防止OutOfMemoryError

当我删除for循环时,我得到一个OutOfMemoryError.当我使用for循环时,我没有得到错误.任何人都可以帮助我理解这种行为吗?

public class JavaMemoryPuzzlePolite {
    private final int dataSize = (int) (Runtime.getRuntime().maxMemory() * 0.6);

    public void f() {
        {
            System.out.println(dataSize);
            byte[] data = new byte[dataSize];
        }
        for (int i = 0; i < 1; i++) {
            System.out.println("Please be so kind and release memory");
        }
        System.out.println(dataSize);
        byte[] data2 = new byte[dataSize];
    }

    public static void main(String[] args) {
        JavaMemoryPuzzlePolite jmp = new JavaMemoryPuzzlePolite();
        jmp.f();
    }
}
Run Code Online (Sandbox Code Playgroud)

java jvm

27
推荐指数
1
解决办法
649
查看次数

Viewpager没有显示在RecyclerView行内

我想制作一个"照片细节"活动或片段,我在其上方和下方显示照片aViewpPager,显示相关照片的评论和喜欢(2个标签).为了使屏幕'Scrollable'所以我可以向上/向下滚动评论和喜欢并向左/向右滑动我决定使用2行的RecyclerView:

第1行:照片(ImageView).

第2行:SlidingTabLayout + ViewPager + FragmentPagerAdapter.

代码编译并运行,显示图像和slidingTabLayout,但不显示ViewPager.

所以我的两个主要问题是:

1-我的实施有什么问题.

2 - 对于我想要达到的目标,是否有替代或更好的解决方案?

注意:我不想使用带有header的listView.我想使用RecyclerView,因为在网络的顶部/底部添加元素更容易.

PhotoDetailsActivity.java

public class MainActivity extends ActionBarActivity {
    RecyclerView recyclerViewPhotoDetails;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        this.recyclerViewPhotoDetails = (RecyclerView) this.findViewById(R.id.recycler_view_photo_details);
        this.recyclerViewPhotoDetails.setLayoutManager(new LinearLayoutManager(this));
        this.recyclerViewPhotoDetails.setAdapter(new PhotoDetailsRecyclerAdapter(this.getSupportFragmentManager()));
    }
}
Run Code Online (Sandbox Code Playgroud)

PhotosDetailsRecyclerAdapter.java

public class PhotoDetailsRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private static final int ROW_IMAGE = 0;
    private static final int ROW_LIKES_AND_COMMENTS = 1;
    private static final int TOTAL_ROWS = 2;

    private FragmentManager fragmentManager;

    public PhotoDetailsRecyclerAdapter(FragmentManager fragmentManager) {
        this.fragmentManager = fragmentManager; …
Run Code Online (Sandbox Code Playgroud)

android android-viewpager android-recyclerview

22
推荐指数
3
解决办法
2万
查看次数

在eclipse中添加org.glassfish.jersey.archetypes

我想在eclipse中创建一个maven项目.我正在尝试创建一个原型,但得到以下错误.

无法解析Archetype org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.16
org.eclipse.core.runtime.CoreException:无法解析工件org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom: 2.16

java eclipse rest glassfish maven

20
推荐指数
4
解决办法
5万
查看次数

使用pip安装时出错

不确定这里有什么,但每次我尝试使用pip安装时我都会收到错误我收到以下错误:

命令"/ usr/bin/python -c"import setuptools,tokenize; __ file __ ='/ private/var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-build-V4hy8S/PySocks/setup.py'; exec(compile(getattr) (tokenize,'open',open)(__ file __).read().replace('\ r \n','\n'),__ file __,'exec'))"install --record/var/folders/b0 /5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-bIOl7C-record/install-record.txt --single-version-external-managed --compile"失败,错误代码为1/private/var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-集结V4hy8S/PySocks

python pip python-2.7

14
推荐指数
2
解决办法
5万
查看次数

如何配置maven shade插件以在我的jar中包含测试代码?

我使用shade maven插件来构建我的项目,以便它的所有依赖项都包含在一个jar中(这使得在Hadoop上运行它更容易).默认情况下,Shade似乎排除了我的测试代码,这是可以理解的.由于我想对我的集群运行集成测试,我希望设置另一个配置文件来为此目的构建一个单独的jar.有没有办法配置这个插件还包括测试代码?

java hadoop maven maven-shade-plugin

13
推荐指数
4
解决办法
1万
查看次数

Maven遮阳罐抛出异常

我有以下例外:

线程"main"中的异常java.lang.SecurityException:在sun.security的sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:380)中没有签名文件条目javax/security/cert/CertificateException.class的最明显部分. util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:231)位于java.util的java.util.jar.JarVerifier.processEntry(JarVerifier.java:288)的sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176) .jar.JarVerifier.update(JarVerifier.java:199)位于sun的java.util.jar.JarFile.getInputStream(JarFile.java:388)的java.util.jar.JarFile.initializeVerifier(JarFile.java:323). misc.URLClassPath $ JarLoader $ 2.getInputStream(URLClassPath.java:692)位于sun.net的sun.misc.Resource.getByteBuffer(Resource.java:144)的sun.misc.Resource.cachedInputStream(Resource.java:61). URLClassLoader.defineClass(URLClassLoader.java:256)at java.net.URLClassLoader.access $ 000(URLClassLoader.java:58)at java.net.URLClassLoader $ 1.run(URLCl)assLoader.java:197)java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at sun .misc.Launcher $ AppClassLoader.loadClass(Launcher.java:301)at java.lang.ClassLoader.loadClass(ClassLoader.java:247)找不到主类:com.mainClass.程序将会退出.

我的pom:

<plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                <version>1.5</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <filter>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>com.mainClass</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
Run Code Online (Sandbox Code Playgroud)

exception maven maven-shade-plugin

12
推荐指数
2
解决办法
5934
查看次数

Android:使Dialog周围的一切都比默认更暗

我有一个以下风格的自定义对话框:

<style name="webtogo_app_style"  parent="@android:style/Theme.Dialog">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

它显示了一个无边框对话框,后面的任何内容都会(稍微)变暗.我的设计师希望背后的一切都比Android的默认设置更暗,但不是完全黑的.

这有什么设置吗?

我能想到的唯一解决方法是使用全屏活动而不是对话框,只需用半透明颜色填充整个屏幕(例如#99000000),然后在其上绘制对话框.有没有更简单的方法?

谢谢!

android background dialog transparent

11
推荐指数
2
解决办法
1万
查看次数