小编Pau*_*BGD的帖子

使用.getDeclaredMethod从扩展另一个类的类中获取方法

所以我想说我正试图从一个类中获取一个方法Method m = plugin.getClass().getDeclaredMethod("getFile");.

但是那个plugin类正在扩展另一个类,即该getFile方法的类.我不太确定是否会使它抛出NoSuchMethodException异常.

我知道plugin扩展的类具有getFile方法.对不起,如果我听起来很混乱,有点累.

java reflection

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

Bootstrap Center Navbar项目

我知道我可以向左和向右推动导航栏项目,但我如何将它们居中?

text-align:center;
Run Code Online (Sandbox Code Playgroud)

不起作用,也没有我想到的任何其他事情.

css twitter-bootstrap

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

从ResourceStream中提取压缩文件会引发错误"无效的存储块长度"

我试图从我当前的JAR中提取ZIP文件:

InputStream resource = getClass().getClassLoader().getResourceAsStream(name);
Run Code Online (Sandbox Code Playgroud)

这是正确的InputStream,但是当我尝试使用以下代码解压缩它时会出错(我将每个文件存储到a中Hashmap<file, filename>):

public static HashMap<String, String> readZip(InputStream inputStream) throws IOException {
    byte[] buffer = new byte[1024];
    HashMap<String, String> list = new HashMap<>();
    ZipInputStream zipInputStream = new ZipInputStream(inputStream);
    ZipEntry entry = zipInputStream.getNextEntry();
    while (entry != null) {
        if (!entry.isDirectory()) {
            StringBuilder stringBuilder = new StringBuilder();
            while (IOUtils.read(zipInputStream, buffer) > 0) {
                stringBuilder.append(new String(buffer, "UTF-8"));
            }
            list.put(stringBuilder.toString(), entry.getName());
        }
        zipInputStream.closeEntry();
        entry = zipInputStream.getNextEntry();
    }
    zipInputStream.closeEntry();
    zipInputStream.close();
    return list;
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试这样做时,我得到了这个例外(上IOUtils.read)

java.util.zip.ZipException: …
Run Code Online (Sandbox Code Playgroud)

java zip embedded-resource maven

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

在运行时扩展类

所以对于这个项目,我试图在运行时扩展一个类.我想知道的是,这甚至可能吗?如果是这样,我该怎么做?那些东西有没有图书馆?

java reflection runtime extend

5
推荐指数
1
解决办法
2093
查看次数

Maven着色错误:访问被拒绝

现在,我已经看到了这个问题,但是看起来没有任何东西正在使用我的目标文件夹.

发生了什么,当我编译它失败并告诉我这个错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project FooProject: Error creating shaded jar: Failed to analyze class dependencies: C:\Users\paul_000\Documents\FooCore\target\classes (Access is denied) -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

我不太清楚为什么会发生这种情况,因为它不会发生在我的普通计算机上.

编辑:我忘了提到,我正在着色的jar在存储库中不存在.我只是在本地编译它(干净安装).同样,这是我用来遮蔽的东西:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <configuration>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <minimizeJar>true</minimizeJar>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

java eclipse access-denied maven

5
推荐指数
1
解决办法
8550
查看次数

我将如何在Java Regex中执行此操作?

试图制作一个正则表达式,抓住所有单词,比如说鸡,不在括号中.所以喜欢

chicken
Run Code Online (Sandbox Code Playgroud)

会被选中但是

[chicken]
Run Code Online (Sandbox Code Playgroud)

不会.有谁知道如何做到这一点?

java regex

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

从 nginx proxy_pass 中删除路径的开头

为了在此服务器上运行的几个应用程序上删除端口的使用,我一直在使用 nginx 的 proxy_pass 来做到这一点。但是,由于某种原因,实际的 url 正在传递给应用程序。有没有办法让它认为/panel真的只是/

location /panel {
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   Host      $http_host;
    proxy_pass         http://127.0.0.1:8082/;
}
Run Code Online (Sandbox Code Playgroud)

nginx proxypass node.js

3
推荐指数
1
解决办法
7001
查看次数

Java Swing - 没有显示的文本和按钮

尝试一切,只是没有出现:

package me.ultimate.ST;

import java.awt.Color;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

public class ST extends JFrame {

    private static final long serialVersionUID = 1L;

    public ST() {
        setSize(500, 600);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setUndecorated(true);
        getContentPane().setBackground(Color.BLACK);
        JLabel label = new JLabel("Test");
        label.setText("Some Test!");
    }

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                ST ex = new ST();
                ex.setVisible(true);
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我得到一个黑盒子.

java swing

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