Home  >  Q&A  >  body text

Java Socket、Hibernate独立使用

有一个需求,需要用Java从Socekt写一个TCP服务供客户端使用,得保证长时间可靠运行,这类型的开发一般是做成什么形式的,写一个可以执行的jar,然后java -jar xx.jar吗?
还有,需要在上面用到数据库,计划用一个现成的ORM框架(比如Hibernate)来免去写sql的麻烦,在这样抛开容器独立运行的情况下Hibernate需要怎么配置,或者有其它相关的ORM框架推荐么?
谢谢!

大家讲道理大家讲道理2712 days ago350

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-17 13:42:16

    A:
    1) If a graphical interface is required, the client can implement it through java/swing
    2) The TCP server is packaged into system Services through Apache Daemon to provide services for clients to call
    3) Hibernate+Spring method, loading the Hibernate framework through Spring
    Resource resource = new FileSystemResource("E:projapplicationContext.xml");
    XmlBeanFactory bean = new XmlBeanFactory(resource);
    Configure Hibernate related parameters in applicationContext.xml
    Or load Hibernate configuration directly

    B:
    1) Change the TCP service you need to implement into web Services. The use of Hibernate is the same as in the web development environment
    2) The client accesses and obtains service data through HttpClient

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 13:42:16

    There was a similar project before.
    The jar method is used,
    If it is a product, if you use java socket to write TCP yourself, stability and performance will be a big problem. It is recommended to use mina or java nio
    Just use hibernate directly, no web environment is required.

    reply
    0
  • Cancelreply