是否可以使用CoreProtocolPNames类的静态最终字段来定义bean,如下所示:
<bean id="httpParamBean" class="org.apache.http.params.HttpProtocolParamBean">
<constructor-arg ref="httpParams"/>
<property name="httpElementCharset" value="CoreProtocolPNames.HTTP_ELEMENT_CHARSET" />
<property name="version" value="CoreProtocolPNames.PROTOCOL_VERSION">
</bean>
Run Code Online (Sandbox Code Playgroud)
public interface CoreProtocolPNames {
public static final String PROTOCOL_VERSION = "http.protocol.version";
public static final String HTTP_ELEMENT_CHARSET = "http.protocol.element-charset";
}
Run Code Online (Sandbox Code Playgroud)
如果有可能,最好的方法是什么?
我正在使用JPA 2.0/Hibernate验证来验证我的模型.我现在有一种情况,必须验证两个字段的组合:
public class MyModel {
public Integer getValue1() {
//...
}
public String getValue2() {
//...
}
}
Run Code Online (Sandbox Code Playgroud)
该模型是无效的,如果这两个getValue1()和getValue2()的null和有效的,否则.
如何使用JPA 2.0/Hibernate执行此类验证?使用简单的@NotNull注释,两个getter都必须为非null才能通过验证.
要求是用户可以写一篇文章,因此我选择mysql数据库中Text的content字段类型.我怎样才能转换Java String成MySQL Text
干得好 Jim Tough
@Entity
public class Article implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Long userId;
private String title;
private String content;
private Integer vote;
//Constructors, setters, getters, equals and hashcode
}
Run Code Online (Sandbox Code Playgroud)
在我的MYSQL数据库中,content是类型Text.我希望会有这样的东西java.sql.Text,因为它java.sql.Blob是一个真实的类型,但遗憾的是,这不存在
我一直试图找到一个JPA Criteria API教程但是没有取得多大成功.你知道任何初学者吗?我想在Java5/Maven应用程序中开始使用它来构建复杂的搜索查询.
我的Java应用程序使用JPA进行对象持久化.业务域非常简单(只有三个类是持久的,每个类有3-5个属性).查询也很简单.问题是我应该使用哪种方法:JPQL或Criteria API?
我想使用maven-dependency-plugin将我的多模块项目的所有子模块中的EAR文件复制到相对于整个项目的根目录的目录.
也就是说,我的布局看起来与此类似,名称已更改:
to-deploy/
my-project/
ear-module-a/
ear-module-b/
more-modules-1/
ear-module-c/
ear-module-d/
more-modules-2/
ear-module-e/
ear-module-f/
...
Run Code Online (Sandbox Code Playgroud)
我希望所有的EAR文件都从它们各自模块的目标目录中复制到my-project/../to-deploy最后
to-deploy/
ear-module-a.ear
ear-module-b.ear
ear-module-c.ear
ear-module-d.ear
ear-module-e.ear
ear-module-f.ear
my-project/
...
Run Code Online (Sandbox Code Playgroud)
我可以在每个耳模块中使用相对路径来完成它,如下所示:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>ear</type>
<outputDirectory>../../to-deploy</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但我宁愿不在<outputDirectory>元素中指定相对路径.我更喜欢类似的东西${reactor.root.directory}/../to-deploy,但我找不到这样的东西.
此外,我更喜欢有一些方法来继承这个maven-dependency-plugin配置,所以我不必为每个EAR模块指定它.
我还尝试从根pom继承自定义属性:
<properties>
<myproject.root>${basedir}</myproject.root>
</properties>
Run Code Online (Sandbox Code Playgroud)
但是当我试图${myproject.root}在耳模块POM中使用时,${basedir}它将解析为耳模块的基础.
另外,我找到了http://labs.consol.de/lang/de/blog/maven/project-root-path-in-a-maven-multi-module-project/,其中建议每个开发人员,大概是连续的集成服务器应该在profiles.xml文件中配置根目录,但我不认为它是一个解决方案.
那么有一种简单的方法可以找到多模块项目的根目录吗?
如何从java servlet中抛出404错误?我的web.xml已经指定了当有404时要显示的页面,如何从servlet中抛出404?
我在注释对象中设置一对多关系时遇到问题.
我有以下内容:
@MappedSuperclass
public abstract class MappedModel
{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id",nullable=false,unique=true)
private Long mId;
Run Code Online (Sandbox Code Playgroud)
那么这个
@Entity
@Table(name="customer")
public class Customer extends MappedModel implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -2543425088717298236L;
/** The collection of stores. */
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Collection<Store> stores;
Run Code Online (Sandbox Code Playgroud)
还有这个
@Entity
@Table(name="store")
public class Store extends MappedModel implements Serializable
{
/**
*
*/
private static final long serialVersionUID = -9017650847571487336L;
/** many stores have a single …Run Code Online (Sandbox Code Playgroud) Sprint和迭代之间是否存在差异,或者Sprint或Sprint中的迭代是否只是Scrum中使用的术语而不是迭代?如果有人可以对此有所了解,将会很有帮助.
假设有4个冲刺并且您已经确定第一个冲刺将持续10天是否需要其他3个冲刺应该具有相同长度的第一个决定冲刺的长度??.
我刚检查了一些项目并需要构建它们,但是我很久以前安装了Maven(可能是6个月?)并且从那时起就没有使用它 - 我所拥有的项目的pom.xml没有这个" http://repo1.maven.org/myurlhere "在其中的任何地方 - 它有maven repo用于项目的绝对URL,但maven仍在尝试从普通的maven repo下载:
Macintosh:trunk$ mvn clean install
[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/url/project/project/x.x/project-x.x.pom
[INFO] Unable to find resource 'url.project:project:pom:x.x' in repository central (http://repo1.maven.org/)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
GroupId: url.project
ArtifactId: project
Version: x.x
Reason: Unable to download the artifact from any repository
url.project:project:pom:x.x
from the specified remote repositories:
central (http://repo1.maven.org/)
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我做正确的事情,基本上我只是从命令行检查项目,cd-ed到目录并运行"mvn clean install" - 没有别的.任何帮助是极大的赞赏.