我有测试实体:
public class Test {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "duration", nullable = false)
private int duration;
@Column(name = "test_name", nullable = false, unique = true)
private String testName;
@Column(name = "archived", nullable = false)
private boolean archived;
@OneToMany(mappedBy = "test", fetch = FetchType.EAGER)
private Set<Question> questions;
@ManyToMany(mappedBy = "tests")
private Set<User> users;
Run Code Online (Sandbox Code Playgroud)
问题实体:
public class Question {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装Checkstyle,包括IntelliJ IDEA中的SevNTU Checkstyle扩展
但是,当我添加配置文件sevntu-checkstyle-default-configuration.xml时出现错误:
org.infernus.idea.checkstyle.exception.CheckStylePluginException: <html><b>The Checkstyle rules file could not be loaded.</b><br>
cannot initialize module TreeWalker - Unable to instantiate com.github.sevntu.checkstyle.checks.design.VariableDeclarationUsageDistanceCheck<br>
The file has been blacklisted for 60s.</html>
at org.infernus.idea.checkstyle.checker.CheckerFactory.blacklistAndShowMessage(CheckerFactory.java:183)
at org.infernus.idea.checkstyle.checker.CheckerFactory.createChecker(CheckerFactory.java:139)
at org.infernus.idea.checkstyle.checker.CheckerFactory.getOrCreateCachedChecker(CheckerFactory.java:84)
at org.infernus.idea.checkstyle.checker.CheckerFactory.checker(CheckerFactory.java:63)
at org.infernus.idea.checkstyle.checker.CheckerFactory.verify(CheckerFactory.java:44)
at org.infernus.idea.checkstyle.ui.LocationDialogue.attemptLoadOfFile(LocationDialogue.java:198)
at org.infernus.idea.checkstyle.ui.LocationDialogue.access$800(LocationDialogue.java:24)
at org.infernus.idea.checkstyle.ui.LocationDialogue$NextAction.actionPerformed(LocationDialogue.java:241)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278) …Run Code Online (Sandbox Code Playgroud) 我想获取一些字段,然后将其设置为我的 Test.entity。我的 SQL 查询:
query = "SELECT t.id as tId, t.test_name, t.duration, q.id as qId, " +
"q.question as question, q.is_multichoice as is_multichoice, " +
"q.is_open as is_open, a.id as aId, a.answer_text as answer_text FROM result r " +
"JOIN test t ON r.test_id = t.id " +
"JOIN user u ON r.user_id = u.id " +
"JOIN question q ON t.id = q.test_id JOIN answer a ON q.id = a.question_id " +
"WHERE t.id = :testId AND u.id = …Run Code Online (Sandbox Code Playgroud) 我愿与工作Aerospike和使用Spring Data。我在这里找到了对我的目标有用的库。
但是,但是将其添加到依赖项中,示例中的这段代码仍然找不到依赖项。
@Configuration
@EnableAerospikeRepositories(basePackageClasses =
ContactRepository.class)
class ApplicationConfig extends AbstractAerospikeConfiguration {
public @Bean(destroyMethod = "close") AerospikeClient aerospikeClient() {
ClientPolicy policy = new ClientPolicy();
policy.failIfNotConnected = true;
return new AerospikeClient(policy, "localhost", 3000);
}
public @Bean AerospikeTemplate aerospikeTemplate() {
return new AerospikeTemplate(aerospikeClient(), "bar");
}
}
Run Code Online (Sandbox Code Playgroud)
在谷歌中可以找到更少的信息。我已经尝试添加另一个存储库,例如:
<repositories>
<repository>
<id>spring-milestone</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)
此外,您可以在此处找到项目示例。你猜怎么着?那也不会建。
我已经安装了最新的Maven、更新的存储库,但仍然没有结果。也许我缺少一些核心依赖项?
编辑:
我已经添加了任何其他依赖项。首先,它根本没有找到,但更新后Maven看起来还可以。但是,我仍然无法导入所需的资源。
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-aerospike</artifactId>
<version>1.5.0.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我是JDBC的新手,我正在尝试更新数据库中的2个表,所以我想在1个事务中执行它,所以如果一个查询失败,另一个也应该失败.我想提供这样的行为,或者只是有机会进行回滚,如果其中一个失败.
这是我的2个查询:
int i = stmt.executeUpdate("INSERT INTO product (title, price, `status`) " +
"VALUES ( \"" + product.getTitle() + "\", " + product.getPrice() + ", " + product.getStatus().ordinal() + ");");
int j = stmt.executeUpdate("INSERT INTO product_categories (product_id, category_id) " +
"VALUES (last_insert_id(), " + categoryId + ");");
Run Code Online (Sandbox Code Playgroud) 我正在使用 Cargo 在 Tomcat 上自动进行战争部署。但是,我遇到了一个麻烦:我无法用我的自定义替换默认的 tomcat 文件,因为我的文件首先被复制,然后默认被覆盖。我花了几个小时来解决这个问题,但没有任何效果。这是我的 pom.xml
\n\n <artifactId>maven-resources-plugin</artifactId>\n <executions>\n <execution>\n <id>replace-tomcat-users-xml</id>\n <phase>process-test-resources</phase>\n <goals>\n <goal>copy-resources</goal>\n </goals>\n <configuration>\n <outputDirectory>${basedir}/target/apache-tomcat-${version.tomcat}/conf/</outputDirectory>\n <resources>\n <resource>\n <directory>src/test/resources/</directory>\n <includes>\n <include>context.xml</include>\n </includes>\n </resource>\n </resources>\n </configuration>\n </execution>\n <execution>\n <id>replace-tomcat-users-xml-cargo</id>\n <phase>process-test-resources</phase>\n <goals>\n <goal>copy-resources</goal>\n </goals>\n <configuration>\n <outputDirectory>${basedir}/target/cargo/installs/tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}</outputDirectory>\n <resources>\n <resource>\n <directory>src/test/resources/</directory>\n <includes>\n <include>context.xml</include>\n </includes>\n </resource>\n </resources>\n </configuration>\n </execution>\n </executions>\n </plugin>\nRun Code Online (Sandbox Code Playgroud)\n\n这是货物使用:
\n\n<plugin>\n <groupId>org.codehaus.cargo</groupId>\n <artifactId>cargo-maven2-plugin</artifactId>\n <version>1.4.11</version>\n <configuration>\n <skip>false</skip>\n <container>\n <containerId>tomcat7x</containerId>\n <log>${project.build.directory}/cargo.log</log>\n <artifactInstaller>\n <groupId>org.apache.tomcat</groupId>\n <artifactId>tomcat</artifactId>\n <version>${version.tomcat}</version>\n <type>zip</type>\n </artifactInstaller>\n <systemProperties>\n <tomcat.home.dir>\n ${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}\n </tomcat.home.dir>\n <tomcat.server.home.dir>\n ${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}\n </tomcat.server.home.dir>\n </systemProperties>\n <dependencies>\n <dependency>\n <groupId>mysql</groupId>\n <artifactId>mysql-connector-java</artifactId>\n </dependency>\n …Run Code Online (Sandbox Code Playgroud) 我的问题很重要。
我应该执行运行INSERT INTO查询的PL / SQL脚本。看起来像:
DECLARE
newId NUMBER(38,0) := &1;
BEGIN
Insert into FOO ("ID", "DESCRIPTION")
values (newId+1, 'LARGE CLOB WHICH PRODUCES EXCEPTION');
-- A LOT OF INSERT QUERIES
END;
/
exit;
Run Code Online (Sandbox Code Playgroud)
因此,我发现将CLOB分配给VARCHAR2变量是一个好主意,因为它可能是32767字节长。我的目标是针对每个INSERT INTO查询执行此操作。喜欢:
--assign CLOB to VARCHAR2 variable
-- INSERT variable instead of CLOB type
Run Code Online (Sandbox Code Playgroud)
我想指出的是,我INSERT INTO在脚本中有很多查询,因此我应该在每个INSERT INTO查询之前重新分配变量,我该怎么做?