小编Ján*_*ček的帖子

连接失败:ECONNREFUSED

我正在开发一个应用程序,我认为我想做的是从android中的服务器数据库接收数据.所以我开始运行一些教程.我找到了一个正在做我想要的东西.但我得到:

detailMessage   "failed to connect to localhost/127.0.0.1 (port 8080): connect failed: ECONNREFUSED (Connection refused)" (id=830021648792) 
Run Code Online (Sandbox Code Playgroud)

本教程的整个代码在这里链接

发生错误:

OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());

我查了一下:

  • 防火墙已禁用
  • ping工作正常
  • 连接字符串与从服务器管理界面运行servlet时完全相同http://localhost:8080/Requestor/RQSRV - servlet正在运行

我的配置:

  • 服务器:Glass Fish 4.0
  • Android应用程序 - 在Eclipse中开发
  • Servlet - 在NetBeans中开发

java android servlets exception connect

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

JsonPath 在 Spring Cloud Data Flow 过滤器组件中无法正常工作

我正在尝试编写一个简单的 SCDF 流,该流从 Kafka 读取,通过特定值的存在过滤消息并将数据推送到 Mongo。作为其中的一部分,我必须按照#jsonPath 编写

 #jsonPath(payload,'$[?(@.metadata!=null)].metadata[?(@.trigger-routing!=
 null)].trigger-routing') == {'1'}
Run Code Online (Sandbox Code Playgroud)

我编写了一个示例测试,它将运行 SPeL 并验证它返回的内容(注意:我有意使用 @EnableIntegration 来连接与 SCDF 相同的 SPeL 功能配置文件,至少这是我的理论)

@SpringBootTest(classes = SpelTst.TestConfiguration.class)
public class SpelTst {

    @Configuration
    @EnableIntegration
    public static class TestConfiguration {

    }

    @Autowired
    IntegrationEvaluationContextFactoryBean factory;

    @Test
    public void test() throws JsonProcessingException {
        final StandardEvaluationContext context = factory.getObject();
        ExpressionParser parser = new SpelExpressionParser();
        Expression exp = parser.parseExpression("#jsonPath(payload,'$[?(@.metadata!=null)].metadata[?(@.trigger-routing!= null)].trigger-routing') == {'1'}");

        final PixelHitMessage sampleOne = new PixelHitMessage()
                .setMetadata(ImmutableMap.of("trigger-routing", "1"))
                .toChildType();

        final PixelHitMessage sampleTwo = new PixelHitMessage()
                .setMetadata(ImmutableMap.of("trigger-routing", ""))
                .toChildType(); …
Run Code Online (Sandbox Code Playgroud)

java spring etl jsonpath spring-cloud-dataflow

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

阴影/重新打包的jar作为依赖项

在这种情况下,我们需要一个应用程序才能连接到两个版本的kafka(0.7.2和0.10.0+)并充当路由器。我试图在这里省略使用两个运行时,因为我们需要快速愚蠢,因此在运行时之间发送数据时要防止额外的序列化/反序列化。

为此,我尝试将旧的kafka驱动程序从软件包kafka重新打包为old.kafka,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>kafka-router</artifactId>
        <groupId>org.deer</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>old-kafka</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <kafka.version>0.7.2</kafka.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.kafka</groupId>
                                    <artifactId>kafka_2.9.2</artifactId>
                                    <version>${kafka.version}</version>
                                    <type>jar</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                    <includes>**/*.class,**/*.xml</includes>
                                </artifactItem>
                            </artifactItems>
                            <includes>**/*.java</includes>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>kafka.</pattern>
                                    <shadedPattern>old.kafka.</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build> …
Run Code Online (Sandbox Code Playgroud)

java maven maven-shade-plugin apache-kafka

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

应用程序关闭后删除了Spring JPA数据

我有一个基于Spring引导的应用程序,使用HSQL数据库上的JPA存储库.

问题是,当应用程序运行时,我创建了一个实体,并且它正确地保存到数据库(可以在数据库管理器中看到).但是从eclipse关闭应用程序后,所有数据都被删除了;

保存是这样执行的

@Service
public class NotificationService {

    @Autowired
    private NotificationRepository notificationRepository;

    public void notifyRefreshArticles(){
        Notification notification = new Notification();
        notification.setCreatedAt(LocalDateTime.now());
        notification.setNotificationSeverity(NotificationSeverity.NORMAL);
        notification.setNotificationType(NotificationType.REFRESH_ARTICLES);

        notificationRepository.save(notification);
    }
}
Run Code Online (Sandbox Code Playgroud)

我很确定它的配置问题,但春天启动基本上只有配置,我有这个配置文件.

spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:hsql://localhost/rr_app_database
spring.datasource.username=XXXXXX
spring.datasource.password=XXXXXX
spring.datasource.show-sql=true
Run Code Online (Sandbox Code Playgroud)

java spring jpa spring-data spring-boot

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

Android Map View 未加载内容

首先,我知道这里有很多关于这个问题的线索,但我都阅读了它们,并尝试了几乎所有的东西。那么我的问题是什么。我正在开发一个带有谷歌地图的应用程序,我也遇到了一个众所周知的问题,即 mapView 加载良好,但它不包含任何内容(只有灰色的空白矩形)。

这是我尝试过的:

  • 我tripplecheck我的API代码
  • 我重新生成我的 API 代码
  • 我检查了所有的权限
  • 还有很多其他的东西

主布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:enabled="true"
    android:apiKey="my key"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

显现:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.gps.gpsclientsoftware"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />



    <application

        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.maps"/> 
        <activity
            android:name="com.gps.gpsclientsoftware.GPSClientActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


    </application>


</manifest>
Run Code Online (Sandbox Code Playgroud)

活动代码:

package com.gps.gpsclientsoftware; …
Run Code Online (Sandbox Code Playgroud)

java android google-maps android-mapview

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

JPanel没有显示添加的组件

我想做一个动态歌曲列表,表示为JPanel歌曲项目也表示为JPanel,添加到父歌曲列表JPanel

这是我的代码/ MainContext类的构造函数

public MainContext() {
        initComponents();
        PanelItem item=new PanelItem();
        songListPanel.add(item);
        item.setEnabled(true);
        item.setVisible(true);
        item.setSongLabel("bla bla");
        songListPanel.revalidate();
    }
Run Code Online (Sandbox Code Playgroud)

这就是我得到的

在此输入图像描述

我想要的是左侧面板将显示多个 PanelItem's

希望你能帮忙

java swing jpanel

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