小编twe*_*sat的帖子

Android 3.2从操作栏中删除标题

我正在使用eclipse,android 3.2.和运行android x86的虚拟机.(V3.2)

我使用Holo主题,我想删除操作栏标题和图标.所以我这样做

@Override
public void onCreate(Bundle savedInstanceState)
{
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test);
}
Run Code Online (Sandbox Code Playgroud)

它工作正常,但......

当应用程序启动时,我首先显示标题和图标,然后才看到它们消失.所以它不是很漂亮.

如果我使用debug,我只能在离开onCreate时才能看到setDisplayShowTitleEnabled生效.

那么有没有办法在活动显示之前隐藏标题和图标?

谢谢.

android

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

添加静态dns条目

什么相当于Windows中的主机文件?

我想添加一个dns条目,所以'sql1'指向localhost.

我尝试将sql1 127.0.0.1添加到/etc/resolveconf/resolv.conf.d/base,然后sudo service resolveconf restart,但它无法正常工作.ping到sql仍然给我未知的主机sql1.

ubuntu-12.04

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

带有可选部分的Java 8 DateTimeFormatter

我有一个字符串代表日期(有或没有时间)喜欢13/12/201713/12/2017 15:39:51

所以我正在尝试将java 8 DateTimeFormatter与可选部分一起使用.

该代码有效

LocalDateTime localDateTime = LocalDateTime.parse("13/12/2017 15:39:51",DateTimeFormatter.ofPattern("dd/MM/yyyy[ HH:mm:ss]"));
System.out.println(localDateTime.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")));
System.out.println(localDateTime.format(DateTimeFormatter.ofPattern("HH:mm:ss")));

13/12/2017
15:39:51
Run Code Online (Sandbox Code Playgroud)

但我不明白为什么那个没有

LocalDateTime localDateTime = LocalDateTime.parse("13/12/2017",DateTimeFormatter.ofPattern("dd/MM/yyyy[ HH:mm:ss]"));
Run Code Online (Sandbox Code Playgroud)

给我

Exception in thread "main" java.time.format.DateTimeParseException: Text '13/12/2017' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2017-12-13 of type java.time.format.Parsed
at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1855)
at java.time.LocalDateTime.parse(LocalDateTime.java:492)
...
Run Code Online (Sandbox Code Playgroud)

甚至还有

LocalDateTime localDateTime = LocalDateTime.parse("13/12/2017",DateTimeFormatter.ofPattern("dd/MM/yyyy"));
Run Code Online (Sandbox Code Playgroud)

它不适用于相同的例外.

time java-8

9
推荐指数
1
解决办法
2839
查看次数

docker 容器中的 curl 证书失败

我有Ubuntu 18.04 server一个coporate proxy.

我设置http_proxyhttps_proxy环境变量。

服务器正在运行Docker 19.03,它也被配置为使用 http_proxy 和 https_poxy。

如果运行docker run -it ubuntu:18.04,在容器内,我可以执行apt updateapt install curl -y

然后我可以做类似的事情curl www.google.com

但它不适用于https

root@1b6abfb4ff90:/# curl -v -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     
0*   Trying 10.30.88.14...
* TCP_NODELAY set …
Run Code Online (Sandbox Code Playgroud)

ssl curl docker ubuntu-18.04

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

XStream序列化空值

假设我有

class Student
{
String name;
int    age;
String teacher;
}
Run Code Online (Sandbox Code Playgroud)

然后 :

public class App1
{
    public static void main(String[] args)
    {
        Student st = new Student();
        st.setName("toto");

        XStream xs = new XStream();

        xs.alias("student",Student.class);

        System.out.println(xs.toXML(st));
    }
Run Code Online (Sandbox Code Playgroud)

}

给我 :

<student>
  <name>toto</name>
  <age>0</age>
</student>
Run Code Online (Sandbox Code Playgroud)

有没有办法处理空值?我的意思是 :

<student>
  <name>toto</name>
  <age>0</age>
  <teacher></teacher>
</student>
Run Code Online (Sandbox Code Playgroud)

如果我这样做是可能的

st.setTeacher("");
Run Code Online (Sandbox Code Playgroud)

但如果老师是空的,那就不行了

我尝试使用自定义转换器,但似乎空值不会发送到转换器.

java serialization xstream

7
推荐指数
1
解决办法
9052
查看次数

ListView带有自定义适配器,逐个添加元素

阅读这个问题,我尝试了答案中给出的例子,它运行正常.现在我想做同样的事情,但使用Student类的自定义适配器.所以我有:

public class AsyncDemo extends ListActivity {
  private static final String[] items={"lorem", "ipsum", "dolor",
                                      "sit", "amet", "consectetuer",
                                      "adipiscing", "elit", "morbi",
                                      "vel", "ligula", "vitae",
                                      "arcu", "aliquet", "mollis",
                                      "etiam", "vel", "erat",
                                      "placerat", "ante",
                                      "porttitor", "sodales",
                                      "pellentesque", "augue",
                                      "purus"};
    private List<Student>  students;
    private StudentAdapter studentsAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

//    setListAdapter(new ArrayAdapter<String>(this,
//                        android.R.layout.simple_list_item_1,
//                        new ArrayList<String>()));

    students = new ArrayList<Student>();
    students.clear();
    studentsAdapter = new StudentAdapter(this, students);
    setListAdapter(studentsAdapter);

    new AddStringTask().execute();
    }

//  class AddStringTask extends …
Run Code Online (Sandbox Code Playgroud)

android android-arrayadapter android-listview baseadapter

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

调用soap webservice从带有轴的java客户端返回对象列表

我厌倦了网络服务.

我有一个非常简单的soap webservice:

@Remote
public interface StudentService
{
public String sayHello();
public List<Student> getStudents();
}
Run Code Online (Sandbox Code Playgroud)

@Stateless
@WebService
public class StudentServiceImpl implements StudentService
{

@Override
public String sayHello()
{
    return "Hello World";
}

public List<Student> getStudents()
{
    List<Student> students = new ArrayList<Student>();

    Student st1 = new Student();
    st1.setMatricule(1234);
    st1.setName("student1");
    students.add(st1);

    Student st2 = new Student();
    st2.setMatricule(5678);
    st2.setName("student2");
    students.add(st2);

    return students;
    }
}
Run Code Online (Sandbox Code Playgroud)

public class Student implements Serializable
{
private static final long serialVersionUID = 8286393242028201686L;

private int matricule; 
private …
Run Code Online (Sandbox Code Playgroud)

java axis web-services glassfish-3

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

Maven - 从战争中排除类文件

我有 :

src/main/java/com.tuto
|
-Class1.java
-Class2.java
-Class3.java

我的pom打包了一场战争.所以在我的战争中,在WEB-INF/classes/com/tuto中我发现了3个类.

现在我想排除Class2.java

我试过了

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1</version>
            <configuration>
              <excludes>
                 <exclude>**/Class2.class</exclude>
              </excludes>
            </configuration>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

我能怎么做 ?


好吧,就像Aaron告诉我的那样,这是有效的:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <packagingExcludes>**/Class2.class</packagingExcludes>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

但......

让我们从另一方面解决问题:我想排除除Class1和Class3之外的所有问题

所以我试过了

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <packagingIncludes>**/Class1.class,**/Class3.class</packagingIncludes>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

而这次它不起作用.

maven-2 war

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

Jenkins管道-用于docker-compose的环境变量

我正在尝试将docker-compose环境变量用于由设置的图像名称,Jenkinsfile但是它不起作用。

我有一个Jenkinsfile包含

node() {

  stage('Checkout') {
    cleanWs()
    git credentialsId: 'xxx', url: 'ssh://git@...'
  }

  stage('Build') {
    withMaven(maven: 'maven-3.5.3') {
      sh 'mvn clean package'
      def pom = readMavenPom file:'pom.xml'
      JAR_FILE = pom.artifactId + "-" + pom.version + ".jar"
      JAR_VERSION = pom.version
    }
  }

  stage('Build Docker Image') {
    echo "Docker Build ..."
    docker.withTool('docker') {
      app = docker.build("microservices/my-service:${JAR_VERSION}","--build-arg JAR_FILE=${JAR_FILE} .")
    }
  }

  stage('Running Docker Container') {
    echo "Docker Run ..."
    withEnv(['VERSION=1.0.0']) {
      docker.withTool('docker') {
        sh "docker-compose rm -f …
Run Code Online (Sandbox Code Playgroud)

jenkins docker docker-compose jenkins-pipeline

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

Spring Boot 普罗米修斯千分尺 - 仪表未更新

我有一个SpringBoot 2.2.4.RELEASE像 RestRepostory 这样的

import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.PostConstruct;

@RestController
public class MyController {

    private MeterRegistry meterRegistry;

    public MyController(MeterRegistry meterRegistry) {
        this.meterRegistry = meterRegistry;
    }

    private Gauge myGauge;
    private Integer myInteger = 0;

    @PostConstruct
    private void init() {
        myGauge = Gauge.builder("my.gauge", myInteger, Integer::intValue)
                .register(meterRegistry);
    }

    @GetMapping("/count")
    public void count() {
        myInteger = 5;
    }

}
Run Code Online (Sandbox Code Playgroud)

应用程序启动后,访问http://localhost:8082/actuator/prometheus可以看到

# HELP my_gauge  
# TYPE my_gauge gauge
my_gauge 0.0
Run Code Online (Sandbox Code Playgroud)

但是访问http://localhost:8082/count/后,该值仍然是 0.0

有什么问题 ?我也不明白构建器函数的第三个参数。是这个原因吗? …

spring-boot prometheus micrometer

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