小编rog*_*hat的帖子

eclipse:clean eclipse:eclipse - maven 命令用法

我有一个 maven 项目,其中我wsimport在项目构建期间使用作为目标的 web 服务。

<build>
  <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.10</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                </execution>
            </executions>
            <!-- -->
            <configuration>
                <wsdlUrls>
                    <wsdlUrl>http://localhost:8081/email-service/services/EmailService?wsdl</wsdlUrl>
                </wsdlUrls>
                <sourceDestDir>${project.build.directory}/generated</sourceDestDir>
                <verbose>true</verbose>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
<finalName>EmailServiceClient</finalName>
Run Code Online (Sandbox Code Playgroud)

我使用clean install命令构建项目。工件/类在target->generated目录中生成。到现在为止还挺好。

现在,当我尝试访问目录中任何生成的类时src,我收到编译器错误,指出该类未定义。我的同行告诉我使用

eclipse:clean eclipse:eclipse
Run Code Online (Sandbox Code Playgroud)

我做到了,它解决了问题。我能够非常轻松地使用这些生成的类。现在我想知道

  • 这个命令实际上发生了什么?
  • 有什么用?
  • 我真的遵循正确的消费方式吗?我知道我也可以使用,wsdl2java但这有什么问题?

有没有人遇到过这种情况?请对此有所了解。谢谢!

eclipse web-services wsimport maven m2e

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

Java 线程:如何一次使用两个线程打印字母和数字

我正在尝试使用 Java 中的线程。虽然我知道线程输出是不可预测的,但是想知道是否有办法做到这一点。

我必须实现两个线程,一个打印字母表(a,b,c...z),另一个打印数字(1,2,3....26)。必须以输出应为a,1,b,2,c,3,d,4......z,26. 下面是我的代码,但它没有给出所需的输出。

public class ThreadsExample {

  public static void main(String[] args) {
    Runnable r = new Runnable1();
    Thread t = new Thread(r);
    Runnable r2 = new Runnable2();
    Thread t2 = new Thread(r2);
    t.start();
    t2.start();
  }
}

class Runnable2 implements Runnable{
  public void run(){
    for(char i='a';i<='z';i++) {
        System.out.print(i+",");
    }
  }
}

 class Runnable1 implements Runnable{
  public void run(){
    for(int i=1;i<=26;i++) {
       System.out.print(i+",");
    }
 }
}
Run Code Online (Sandbox Code Playgroud)

我应该在代码中进行哪些调整以获得所需的输出?如何synchronization帮助这里?或者在使用 Threads 时真的有可能吗?

PS:这不是作业或练习。它的自学。

java multithreading thread-synchronization

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

如何添加网络安全配置以在 Nougat 中启用 Charles 代理 SSL?

我正在尝试Charles ProxySamsung s8运行时启用SSL ,Android Nougat但不知道如何操作。

Nougat我能够在我的设备上成功记录多个应用程序的查尔斯会话之前。

已按照设置所有内容,但这是在 Android 中启用 Charles 时要遵循的第一步。我的用例与其他问题中的用例不同,因为我正在监视第三方应用程序并且我没有任何AndroidManifest.xmlres目录来创建network_configuration文件。

也经历了网络安全配置和做什么,但不知道如何。

有没有办法为我设备中的所有第三方应用程序启用代理?有什么方法可以将此网络配置添加到设备本身而不是单个应用程序?

感谢帮助。

ssl android android-7.0-nougat charles-proxy

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

数组中两个不同元素之间的最大距离

我有一个问题,我需要找到一个数组中两个不同元素之间的最大距离.

例如:给定一个数组4,6,2,2,6,6,4,该方法应返回5最大距离.

我能够使用两个for循环来解决问题,但它不是一个优化的解决方案.我试图通过在单个for循环中进行优化来优化它.

这是我目前的解决方案:

int [] A = {4,6,2,2,6,6,4};
int N = A.length;
int result = 0;

for (int i = 0; i < N; i++){
    for (int j = i; j < N; j++) {
        if(A[i] != A[j]){
            result = Math.max(result, j - i);
        }
    }
}

// tried below code but it is not efficient
//      for (int i = 0; i < N; i++){
//          
//          if(A[N-1] != A[i]){
//              result = Math.max(result, …
Run Code Online (Sandbox Code Playgroud)

java arrays algorithm integer

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

编程:将二进制数转换为零所需的最少步骤

正在从事编程工作,并被困于找出正确的算法。这是问题所在:

给定一个十进制数,需要多少个最小可能的步骤才能将其转换为零:

  1. 如果下一位i + 1为'1',则更改位i,其余所有其他位i + 2及更高版本为0。
  2. 无限制地更改最后一位

例如:
如果输入为(8)Base10 =(1000)Base2,则采取的步骤为:

1000?1001?1011?1010?1110?1111?1101?1100?0100?0101?0111?0110?0010?0011?0001?0000
Run Code Online (Sandbox Code Playgroud)

总共需要15个步骤。

完成以下定义:

int minStepsRequired(long number)
Run Code Online (Sandbox Code Playgroud)

可以获取伪代码或仅获取算法。这不是家庭作业或作业。

java algorithm bit-manipulation

4
推荐指数
3
解决办法
1077
查看次数

用于JAX-WS org.codehaus.mojo的Eclipse m2e连接器

我正在尝试使用wsimportmaven build中声明的目标来使用web服务.但我正面临着这个问题m2e connectors.我的POM中有一个错误

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:jaxws-maven-
          plugin:1.10:wsimport (execution: default, phase: generate-sources)
Run Code Online (Sandbox Code Playgroud)

我一直在尝试安装m2e连接器,但即使在市场上也没有.还有其他m2e连接器,但不是我需要的JAX-WS.

我已经关注并尝试了几乎所有这里提到的解决方案,但都是徒劳的.

虽然生成资源没有问题.资源是在构建时成功生成的,但是这个POM错误不允许我的项目与我的tomcat同步,每次我必须手动部署war来测试我做的一些小改动.

这一切真的很烦人,我需要找到解决方案.我在这里使用eclipse juno.下面是我正在使用的POM文件

<build>
    <finalName>home</finalName>
    <plugins>       
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.10</version>
            <executions>
                <execution>
                    <phase>post-clean</phase>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                </execution>
            </executions>
            <!-- -->
            <configuration>
                <wsdlUrls>
                    <wsdlUrl>http://localhost:8080/email-service/services/EmailService?wsdl</wsdlUrl>
                </wsdlUrls>
                <sourceDestDir>${project.build.directory}/generated</sourceDestDir>
                <verbose>true</verbose>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>additional-resources</id> …
Run Code Online (Sandbox Code Playgroud)

eclipse wsimport maven m2e eclipse-juno

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

给定一个按行排序的布尔矩阵.返回最大数为1的行

我遇到了Matrices的一个问题,但我正试图找出最佳解决方案.问题陈述是问题主题本身.进一步见下文

Example
Input matrix

  0 1 1 1
  0 0 1 1
  1 1 1 1  // this row has maximum 1s
  0 0 0 0

Output: 2
Run Code Online (Sandbox Code Playgroud)

我的解决方案:现在,由于行已排序,我想在第一次出现1的每一行中执行二进制搜索,然后计数为1 total number of columns minus index of 1st 1.

这样做会O(m*logn),但我很想知道逻辑是否可以在线性时间内完成.

谢谢!

arrays algorithm binary matrix binary-matrix

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

Java:查找没有任何数字且至少有一个大写字符的最长子字符串

遇到一个编程练习并被卡住了。问题是:

您需要为电子邮件定义一个有效的密码,但唯一的限制是:

  • 密码必须包含一个大写字符

  • 密码不能有数字

    现在,给定一个字符串,找到有效密码的最长子字符串的长度。例如Input Str = "a0Ba",输出应为 2,因为“Ba”是有效子字符串。

我使用了最长子字符串而不重复字符的概念,我之前已经这样做过,但无法修改它来找到上述问题的解决方案。我的不重复字符的最长子字符串的代码是:

public int lengthOfLongestSubstring(String s) {
    int n = s.length();
    Set<Character> set = new HashSet<>();
    int ans = 0, i = 0, j = 0;
    while (i < n && j < n) {
        // try to extend the range [i, j]
        if (!set.contains(s.charAt(j))){
            set.add(s.charAt(j++));
            ans = Math.max(ans, j - i);
        }
        else {
            set.remove(s.charAt(i++));
        }
    }
    return ans;
}
Run Code Online (Sandbox Code Playgroud)

java string algorithm data-structures

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

Java:在不知道输入行数的情况下读取输入

这可能是非常非常基本的,或者可能是我完全缺少的东西。我已经开始在在线频道上做一些竞争性的节目。我必须读取逗号分隔的字符串并对其进行一些操作,但问题是我不知道输入的行数。下面是输入示例

输入1

John,Jacob
Lesley,Lewis
Remo,Tina
Brute,Force
Run Code Online (Sandbox Code Playgroud)

输入2

Hello,World
Java,Coder
........
........
//more input lines
Alex,Raley
Michael,Ryan
Run Code Online (Sandbox Code Playgroud)

我正在尝试读取输入并在遇到行尾时中断,但没有运气。这就是我一直在尝试的

//1st method
Scanner in = new Scanner(System.in);

do{
    String relation = in.nextLine();
    //do some manipulation
    System.out.println(relation);

}while(in.nextLine().equals(""));   //reads only first line and breaks

//2nd method
Scanner in = new Scanner(System.in);
while(in.hasNext()){
    String relation = in.next();
    System.out.println(relation);
    if(relation.equals("")){
        break;
    }
}

//3rd method
Scanner in = new Scanner(System.in);
while(true){   //infinite loop
    String relation = in.nextLine();
    System.out.println(relation);
    if(relation.equals("")){
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

PS:请不要评判。我是竞争性编程的新手,尽管我知道如何在 java 中获取用户输入以及 …

java input java.util.scanner

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

CSS3:每次从画布墙反弹时改变球的颜色

我必须用HTML5/CSS3创建一个球类游戏.同样可以看到JSFiddle.

现在我想要的是每次从墙上反弹时改变球的颜色.

var context;
var dx = 4;
var dy = 4;
var y = 150;
var x = 10;

function draw() {
  context = myCanvas.getContext('2d');
  context.clearRect(0, 0, 300, 300);
  context.beginPath();
  context.arc(x, y, 20, 0, Math.PI * 2, true);
  context.closePath();
  context.fill();
  if (x < 0 || x > 300)
    dx = -dx;
  if (y < 0 || y > 300)
    dy = -dy;
  x += dx;
  y += dy;
}

setInterval(draw, 10);
Run Code Online (Sandbox Code Playgroud)
#container {
  text-align: center;
}
#myCanvas …
Run Code Online (Sandbox Code Playgroud)

javascript html5 canvas css3

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