我有2个模式A,B.我在B中重用了一些A元素.
我不使用命名空间.
我正在使用
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.9.0</version>
Run Code Online (Sandbox Code Playgroud)
我已经在模式B中定义了模式A的包含:
<xs:include schemaLocation="classpath:my.schema.A.xsd"/>
Run Code Online (Sandbox Code Playgroud)
和目录为
REWRITE_SYSTEM "classpath:my.schema.A.xsd" "maven:my.schema:schema-a!/A.xsd"
Run Code Online (Sandbox Code Playgroud)
jaxb配置如下:
<configuration>
<generatePackage>my.schema.b</generatePackage>
<schemaIncludes>
<includes>B.xsd</includes>
</schemaIncludes>
<episodes>
<episode>
<groupId>my.schema</groupId>
<artifactId>schema-a</artifactId>
</episode>
</episodes>
<catalog>src/main/catalog/catalog.cat</catalog>
</configuration>
Run Code Online (Sandbox Code Playgroud)
问题在于,每当我指定episode依赖项时,架构都不会生成任何类,即使它包含一些我希望为其生成类的B元素.
[INFO] Parsing input schema(s)...
[INFO] Compiling input schema(s)...
[INFO] Cleaning package directories.
[INFO] Finished execution.
Run Code Online (Sandbox Code Playgroud)
当我删除这一集时,它运作良好,并为模式A生成类 - 我确实想避免.
你有什么建议吗?
一个样本发表在Jaxb情节汇编中
这是一个非常简单的DAO尝试,我想分享.
我的问题是,这是否是测试DAO的正确方法.我的意思是我正在验证SQL查询并给它返回一个模拟.然后告诉mock返回这些特定值并断言它们?
我已经更新了DAO以使用预处理语句而不是简单的Statement.谢谢.
public class PanelDao implements IO {
private final static Logger LOGGER = Logger.getLogger(PanelDao.class);
private Connection connection;
public PanelDao() throws SQLException {
this(MonetConnector.getConnection());
}
public PanelDao(Connection connection) throws SQLException {
this.connection = connection;
}
@Override
public void save(Panel panel) throws SQLException {
final String query = "INSERT INTO panels VALUES ( ?, ?, ?, ?, ?, ?, ? )";
final PreparedStatement statement = connection.prepareStatement(query);
statement.setString(1, panel.getId());
statement.setString(2, panel.getColor());
statement.setDate(3, (new Date(panel.getPurchased().getTime())) );
statement.setDouble(4, panel.getCost());
statement.setDouble(5, panel.getSellingPrice()); …Run Code Online (Sandbox Code Playgroud) 如果可以实现它,你能看看我的连接池吗?
public class ConnectionPool {
private static List<DBConnection> pool = null;
private static int available = 0;
private ConnectionPool() {}
public static DBConnection getConnection() {
if (pool == null) {
pool = new ArrayList<DBConnection>();
for (int i = 0; i < 3; i++) {
try {
pool.add(new DBConnection());
available++;
} catch (SQLException e) {
e.printStackTrace();
}
}
}
if (pool.size() > 0) {
available--;
return pool.remove(available);
} else {
return null;
}
}
public static void returnConnection(DBConnection c) {
pool.add(c); …Run Code Online (Sandbox Code Playgroud) 这个问题是比较Java中包含的日期.
有没有更好的方法来检查给定日期是否包含在一个范围内?
Date startDate, endDate, dateToCheck;
if ( dateToCheck.equals(startDate) ||
dateToCheck.equals(endDate) ||
(dateToCheck.after(startDate) && dateToCheck.before(endDate) )
Run Code Online (Sandbox Code Playgroud)