簡體   English   中英

將EJB模塊打包為EAR或JAR?

[英]package EJB module as EAR or JAR?

你好,這個世界EJB應該打包為EARJAR進行部署嗎?

thufir@dur:~/NetBeansProjects/EJBModule1$ 
thufir@dur:~/NetBeansProjects/EJBModule1$ cat src/java/net/bounceme/dur/ejb/NewSessionBean.java 
package net.bounceme.dur.ejb;

import java.util.logging.Logger;
import javax.ejb.Stateless;

@Stateless(name = "FooBean", mappedName = "ejb/FooBean")
public class NewSessionBean implements NewSessionBeanRemote {

    private final static Logger log = Logger.getLogger(NewSessionBean.class.getName());

    @Override
    public void sayHello() {
        log.info("hi");
    }

}
thufir@dur:~/NetBeansProjects/EJBModule1$ 

部署:

thufir@dur:~/NetBeansProjects/EJBModule1$ 
thufir@dur:~/NetBeansProjects/EJBModule1$ asadmin list-applications
Nothing to list.
No applications are deployed to this target server.
Command list-applications executed successfully.
thufir@dur:~/NetBeansProjects/EJBModule1$ 
thufir@dur:~/NetBeansProjects/EJBModule1$ ant -p
Buildfile: /home/thufir/NetBeansProjects/EJBModule1/build.xml
Builds, tests, and runs the project EJBModule1.
Main targets:

 -profile-pre72         Profile a J2EE project in the IDE.
 clean                  Clean build products.
 compile                Compile project.
 debug                  Debug project in IDE.
 default                Build whole project.
 dist                   Build distribution (JAR).
 dist-directory-deploy  Build distribution (JAR) - if directory deployment is not supported.
 dist-ear               Build distribution (JAR) to be packaged into an EAR.
 javadoc                Build Javadoc.
 profile                Profile a J2EE project in the IDE.
 run                    Deploy to server.
 test                   Run unit tests.
 test-single            Run single unit test.
 test-single-method     Run single unit test.
Default target: default
thufir@dur:~/NetBeansProjects/EJBModule1$ 
thufir@dur:~/NetBeansProjects/EJBModule1$ ant run
Buildfile: /home/thufir/NetBeansProjects/EJBModule1/build.xml

-pre-init:

-init-private:

-init-userdir:

-init-user:

-init-project:

-init-macrodef-property:

-do-init:

-post-init:

-init-check:

-init-ap-cmdline-properties:

-init-macrodef-javac-with-processors:

-init-macrodef-javac-without-processors:

-init-macrodef-javac:

-init-macrodef-test-impl:

-init-macrodef-junit-init:

-init-macrodef-junit-single:

-init-test-properties:

-init-macrodef-junit-batch:

-init-macrodef-junit:

-init-macrodef-junit-impl:

-init-macrodef-testng:

-init-macrodef-testng-impl:

-init-macrodef-test:

-init-macrodef-junit-debug:

-init-macrodef-junit-debug-batch:

-init-macrodef-junit-debug-impl:

-init-macrodef-test-debug-junit:

-init-macrodef-testng-debug:

-init-macrodef-testng-debug-impl:

-init-macrodef-test-debug-testng:

-init-macrodef-test-debug:

-init-macrodef-java:

-init-debug-args:

-init-macrodef-nbjpda:

-init-macrodef-debug:

-init-taskdefs:

-init-ap-cmdline-supported:

-init-ap-cmdline:

init:

-init-cos:

-init-deploy:

-deps-module-jar:

-deps-ear-jar:

deps-jar:

-pre-pre-compile:

-pre-compile:

-copy-meta-inf:

-do-compile:

-post-compile:

compile:

-library-inclusion-in-archive-weblogic:

-library-inclusion-in-archive-by-user:

library-inclusion-in-archive:

-pre-dist:

-do-tmp-dist-without-manifest:

-do-tmp-dist-with-manifest:

-do-dist-directory-deploy:

-post-dist:

dist-directory-deploy:

pre-run-deploy:

-pre-nbmodule-run-deploy:

-run-deploy-nb:

-init-deploy-ant:

-init-cl-deployment-env:

-parse-glassfish-web:

-parse-sun-web:

-no-parse-sun-web:

-add-resources:

-deploy-ant:

-deploy-without-pw:
     [echo] Deploying dist/EJBModule1.jar
      [get] Getting: http://localhost:4848/__asadmin/deploy?path=/home/thufir/NetBeansProjects/EJBModule1/dist/EJBModule1.jar&force=true&name=EJBModule1
      [get] To: /tmp/gfv3945180939
   [delete] Deleting: /tmp/gfv3945180939

-deploy-with-pw:

-run-deploy-am:

-post-nbmodule-run-deploy:

post-run-deploy:

-do-update-breakpoints:

run-deploy:

run:

BUILD SUCCESSFUL
Total time: 1 second
thufir@dur:~/NetBeansProjects/EJBModule1$ 
thufir@dur:~/NetBeansProjects/EJBModule1$ asadmin list-applications
EJBModule1  <ejb>  
Command list-applications executed successfully.
thufir@dur:~/NetBeansProjects/EJBModule1$ 
thufir@dur:~/NetBeansProjects/EJBModule1$ cat src/java/net/bounceme/dur/ejb/NewSessionBean.java 
package net.bounceme.dur.ejb;

import java.util.logging.Logger;
import javax.ejb.Stateless;

@Stateless(name = "FooBean", mappedName = "ejb/FooBean")
public class NewSessionBean implements NewSessionBeanRemote {

    private final static Logger log = Logger.getLogger(NewSessionBean.class.getName());

    @Override
    public void sayHello() {
        log.info("hi");
    }

}
thufir@dur:~/NetBeansProjects/EJBModule1$ 

這只是一個“模塊”; 據我了解,這意味着沒有Web組件( WAR文件)。 但它仍然可能是一個EAR ......或沒有?

(構建文件/ etc都是Netbeans的默認設置。)

Ear用於將Jar模塊和war模塊捆綁在一起。 因此,當您的企業應用程序具有以下功能時,Ear模塊才有意義:

  • 多個Jar模塊
  • 多個戰爭模塊
  • 多個Jar和war模塊。

另外,在上述設置中還有類路徑的含義。

如果我的應用程序只有一個jar模塊或war模塊,則可以直接部署它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM