这是POM的一部分
...
<groupId>com.soft</groupId>
<artifactId>config-ear</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<name>Enterprise Application</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsgen</goal>
</goals>
<configuration>
<sei>com.soft.WebService</sei>
<genWsdl>true</genWsdl>
<keep>true</keep>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<version>1.4</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
</plugins>
</build>
...
Run Code Online (Sandbox Code Playgroud)
运行mvn clean install
[clean:clean]
Deleting directory D:\Development\config-ear\target
[ear:generate]
Generating application.xml
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory D:\Development\config-ear\src\main\resources
[jaxws:wsgen]
Class not found: "com.soft.WebService"
Run Code Online (Sandbox Code Playgroud)
此类在src / main …
@XmlType
@XmlAccessorType(XmlAccessType.FIELD) // here I need this access
public class User implements Serializable
{
// ...
@XmlTransient
private Set<Values> values;
// ...
@XmlElement
private Set<History> getXmlHistory()
{
return new CustomSet<Values, History>(Values);
}
private void setXmlHistory(final Set<History> aHistory)
{
this.values = new HashSet<Values>();
}
}
Run Code Online (Sandbox Code Playgroud)
当我在Java代码中创建User对象并在创建XML之后,通常都是.
但是当我尝试从XML获取User-object时,则values始终是field null.所以setter不在这里工作.可能setter也需要一些注释吗?
XML看起来像
<user>
...
<xmlHistory>
// ... record 1
</xmlHistory>
<xmlHistory>
// ... record 2
</xmlHistory>
</user>
Run Code Online (Sandbox Code Playgroud) 我有一个内置ejb模块的EAR应用程序和SomeService:
some-ear.ear -> some-ejb.jar -> SomeBean implements ISomeBean
Run Code Online (Sandbox Code Playgroud)
在Java EE规范中,我看到这个bean的JNDI名称应该是
java:comp/env/ISomeService
Run Code Online (Sandbox Code Playgroud)
当我部署我的应用程序上的WebLogic 10.3 ,然后new InitialContext().lookup("java:comp/env/ISomeService");运行良好
现在我在JBoss 4.2.3上部署这个应用程序,我在日志中看到以下内容:
DEBUG [org.jboss.ejb3.stateless.BaseStatelessProxyFactory] Binding proxy for SomeBean in JNDI at some-ear/SomeBean/local
Run Code Online (Sandbox Code Playgroud)
我的天啊!我的bean的JNDI名称是- some-ear/SomeBean/local并且
new InitialContext().lookup("java:comp/env/ISomeService");- 不工作
new InitialContext().lookup("some-ear/SomeBean/local");- 效果很好
现在我在GlassFish 3.1上部署我的应用程序,我在日志中看到以下内容:
Portable JNDI names for EJB SomeBean : [java:global/some-ear/some-jar/SomeBean ...
Run Code Online (Sandbox Code Playgroud)
再次新的JNDI名称!
new InitialContext().lookup("java:global/some-ear/some-jar/SomeBean"); - 效果很好
你能解释一下为什么在不同的AS上存在同一个bean的不同JNDI名称,以及为什么这个JNDI名称与Java EE规范不同?
java中的Util类可以用两种方式制作
class Utils
{
public static ReturnType someUtilMethod(
// ...
}
Run Code Online (Sandbox Code Playgroud)
并执行util方法
Utils.someUtilMethod(...);
Run Code Online (Sandbox Code Playgroud)
或者我可以做
class Utils
{
public Utils(){}
public ReturnType someUtilMethod(
// ...
}
Run Code Online (Sandbox Code Playgroud)
并执行util方法
new Utils().someUtilMethod(...)
Run Code Online (Sandbox Code Playgroud)
什么方式更好?这种方式之间有些差异吗?
#!/bin/ksh
##########################################################################
$JAVA_HOME/bin/java -jar SocketListener.jar 8182
run_something_else
exit 0
Run Code Online (Sandbox Code Playgroud)
SocketListener启动,shell正在等待,而SocketListener不会死.
如何同时运行run_something_else和SocketListener
我有下一个包结构
webService.ear --dependency.jar -- some.class
我可以使用 cmd 脚本和 bash 脚本从 .ear 中删除some.class吗?
解决方案:
我为此编写了 cmd 脚本:
call unzip target\webService.ear -d tmp
call zip -d target\tmp\dependency.jar \com\mypackage1\MyClass1.class
call zip -d target\tmp\dependency.jar \com\mypackage2\MyClass2.class
call jar cvfM target\webService.ear -C tmp .
Run Code Online (Sandbox Code Playgroud)
可能是,这对某人有帮助
我希望通过char比较使用char来断言文件.最好的方法是什么?没有第三方库.哪个文件阅读器最适合这个?
我有Maven项目,但在其中一台服务器上我必须在没有Maven的情况下构建它.
可以使用标准JDK命令.在哪里可以看到Maven在构建项目时发送给JDK的命令?
我们有两个拦截器.输入拦截器Phase.RECEIVE和输出拦截器Phase.SETUP_ENDING
public class BeforeInterceptor extends AbstractPhaseInterceptor<Message>
{
public BeforeInterceptor()
{
super(Phase.RECEIVE);
}
Run Code Online (Sandbox Code Playgroud)
和
public class AfterInterceptor extends AbstractPhaseInterceptor<Message>
{
public AfterInterceptor()
{
super(Phase.SETUP_ENDING);
}
Run Code Online (Sandbox Code Playgroud)
现在我想知道:这两个阶段之间有多少时间?
我必须调用System.currentTimeMillis();BeforeInterceptor,将此值转换为AfterInterceptor,并
System.currentTimeMillis() - valueFromBeforeInterceptor在拦截器后调用.
但是如何从另一个拦截器传输数据呢?
我们假设我已经定义了以下实体:
@Entity
class User{
@Id
@GeneratedValue
@Column(name = "DB_ID")
private long id;
@Id
@Column(name = "LOGIN", unique = true)
private String code;
//setters, getters
}
Run Code Online (Sandbox Code Playgroud)
问题#1.
当我使用该方法时.find(User.class, someId),我必须设置什么ID?我应该使用长字段ID还是字符串字段代码?或者我可以同时使用长字段ID和字符串字段代码吗?
问题2.
如果我想使用该方法.merge(user),在哪种情况下记录会更新?
情况#1: - id等于DB_ID,代码不等于LOGIN
情况#2: - id不等于DB_ID,代码等于LOGIN
情况#3: - idequals DB_ID和代码等于LOGIN
或任何其他条件?