小编mos*_*she的帖子

编写Java FTP服务器

我正在尝试编写一个代码,在我的独立服务器上打开一个FTP服务器,所以我可以将文件从它复制到另一台计算机的客户端,相反,但我对服务器端编程很新,不明白如何.

我得到了Apache FtpServer,但对它的使用有点困惑,我正在寻找如何使用它的基本步骤.也许是这样的:

  1. 做连接命令
  2. 登录
  3. 做一些事......

java ftp ftp-server

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

无法在多播委托中获取第一个方法名称

我有这个代码:

public void AddMenuRow(FuncInvoker i_FuncToAdd)   //  add a row to menu.
{
    if (d_Lines == null)
    {
        d_Lines = new FuncInvoker(i_FuncToAdd);
    }
    else
    {
        d_Lines += i_FuncToAdd;
    }
}
Run Code Online (Sandbox Code Playgroud)

用于向调用列表添加方法.

现在我想将每个方法的名称打印到控制台,所以我做了这个:

public void Show()
{
    int count = 1;
    string name = null;

    Console.WriteLine(m_Title);
    foreach (FuncInvoker list in d_Lines.GetInvocationList())
    {
        name = list.Method.Name;
        Console.WriteLine((count++) + ". " + name);
    }
}   
Run Code Online (Sandbox Code Playgroud)

问题在于第一个方法名称,由于某种原因总是打印"调用".委托链接中的下一个方法工作正常.

有人可以帮我弄这个吗?我尝试了一切.

.net c# delegates

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

使用glassfish进行数据库连接的持久性异常

我是玻璃鱼和持久性的新手,当我试图在我的机器上运行MySQL数据库查询时,我收到以下错误:

异常[EclipseLink-4002](Eclipse Persistence Services - 2.3.2.v20111125-r10461):org.eclipse.persistence.exceptions.DatabaseException内部异常:java.sql.SQLException:未选择数据库错误代码:1046

在运行服务器之前,我确保使用本指南完成服务器配置:使用连接器和glassfish的mysql站点手册,并配置我的persistence.xml,如下所示:

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="StudentRecipieWebsite" transaction-type="RESOURCE_LOCAL">
    <non-jta-data-source>jdbc/mySql</non-jta-data-source>
    <class>il.musehunter.studentRecipes.dbModel.Image</class>
    <class>il.musehunter.studentRecipes.dbModel.Ingrediant</class>
    <class>il.musehunter.studentRecipes.dbModel.Recipe</class>
    <class>il.musehunter.studentRecipes.dbModel.User</class>
    <properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/recipes_data"/>
        <property name="javax.persistence.jdbc.user" value="root"/>
        <property name="javax.persistence.jdbc.password" value="moshe1475"/>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        <property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
    </properties>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)

我对此非常陌生,对我接下来应该做什么没有任何线索,所以任何帮助都会非常感激.

编辑:

从我的glassfish服务器添加部分domain.xml:

<applications>
<application context-root="/StudentRecipieWebsite" location="${com.sun.aas.instanceRootURI}/applications/StudentRecipieWebsite/" name="StudentRecipieWebsite" object-type="user">
  <property name="appLocation" value="${com.sun.aas.instanceRootURI}/applications/__internal/StudentRecipieWebsite/StudentRecipieWebsite.war"></property>
  <property name="org.glassfish.ejb.container.application_unique_id" value="89812698949156864"></property>
  <property name="org.glassfish.persistence.app_name_property" value="StudentRecipieWebsite"></property>
  <property name="defaultAppName" value="StudentRecipieWebsite"></property>
  <module name="StudentRecipieWebsite">
    <engine sniffer="ejb"></engine>
    <engine sniffer="security"></engine>
    <engine sniffer="jpa"></engine>
    <engine sniffer="web"></engine>
  </module>
</application>
Run Code Online (Sandbox Code Playgroud)

和:

<resources>
<jdbc-resource pool-name="__TimerPool" jndi-name="jdbc/__TimerPool" object-type="system-admin"></jdbc-resource> …
Run Code Online (Sandbox Code Playgroud)

mysql persistence glassfish

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

Docker 每个网络端口映射

我正在寻找一种方法将同一端口映射到两个不同的端口,每个端口用于不同网络中的另一个容器。考虑以下 docker-compose 场景:

services:

  web:
    build: .
    ports:
      - "8080:8080"
    networks:
      Net1:
      Net2:

  serv1:
    image: tomcat:7.0.92-jre8
    networks:
      Net1:
  serv2:
    image: tomcat:7.0.92-jre8
    networks:
      Net2:
Run Code Online (Sandbox Code Playgroud)

现在我真正想做的是实际映射“web”服务端口 8080,以便 serv1 可以将其用作 8081,而 serv2 将其用作 8082。

这可能吗?

谢谢

docker docker-compose docker-network

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