我刚刚在我的Ubuntu 11.10上下载了Tomcat 7.0.23软件包.
我按照Google API网站上的说明部署了他们的示例网络应用程序.它基本上由jar
放在WEB-INF/lib
目录中的web.xml
文件和放在WEB-INF
目录中的文件组成.
然而,应用程序没有自动部署,当试图强制服务器通过管理器gui部署它时,我收到以下消息:
FAIL - Application at context path /myWebApp could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException:
Failed to start component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myWebApp]]
Run Code Online (Sandbox Code Playgroud)
但是,Tomcat提供的JSP示例确实有效!
我在Tomcat6上遇到同样的问题.
那我做错了什么?这是权限问题吗?(我甚至尝试将所有文件的mod更改为777).
MOTHER
感谢JPQL查询,我试图删除大量的行.
所述Mother
类的定义如下:
@Entity
@Table(name = "MOTHER")
public class Mother implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "mother",
orphanRemoval = true)
private List<Child> children;
}
@Entity
@Table(name = "CHILD")
public class Child implements Serializable {
@ManyToOne
@JoinColumn(name = "MOTHER_ID")
private Mother mother;
}
Run Code Online (Sandbox Code Playgroud)
如您所见,Mother
该类具有"子",并在执行以下查询时:
String deleteQuery = "DELETE FROM MOTHER WHERE some_condition";
entityManager.createQuery(deleteQuery).executeUpdate();
Run Code Online (Sandbox Code Playgroud)
抛出异常:
ERROR - ORA-02292: integrity constraint <constraint name> violated -
child record found
Run Code Online (Sandbox Code Playgroud)
当然,我可以首先选择我要删除的所有对象,然后在迭代它之前将它们检索到列表中以删除所有检索到的对象,但是这样的解决方案的性能会很糟糕!
那么有没有办法利用前面的映射来有效地删除所有Mother
对象和Child
与它们相关的所有对象,而无需首先为所有子项编写查询?
在Spark中,groupByKey函数将一(K,V)
对RDD转换为一(K,Iterable<V>)
对RDD.
然而,这个功能稳定吗?ie是从原始顺序保留的可迭代顺序?
例如,如果我最初读取表单的文件:
K1;V11
K2;V21
K1;V12
Run Code Online (Sandbox Code Playgroud)
我的迭代K1
可能是(V12, V11)
(因此不保留原始顺序)或者只能是(V11, V12)
(因此保留原始顺序)?
我正在使用jaxb2 xjc
插件从a生成java文件XSD
.因此,我曾经按如下方式配置我的pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.mypackage.model</packageName>
<schemaDirectory>${basedir}/src/main/resources/XSD</schemaDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我将我的开发环境改为Eclipse Indigo,这不再适用了.错误说:"生命周期配置未涵盖插件执行".我知道我必须以不同的方式定义我的插件的执行,以便它在我的新环境中工作.
我按照本页上的说明M2E插件执行未涵盖但执行generate-sources
阶段时未生成源文件.
任何人都可以告诉我如何精确重构我的pom,以便我的文件正确生成?
谢谢你的帮助!
这是我的问题:在我的Java程序中的某个时刻,我使用Spring的SimpleJdbcTemplate类从数据库中获取(非常)大的事件列表.
List<Event> events =
this.simpleJdbcTemplate.query(myQuery,
myMapper(),
new Object[] {
filter.getFirst(),
filter.getSecond(),
filter.getThird()}
);
Run Code Online (Sandbox Code Playgroud)
问题是该列表可能包含600,000个事件...因此使用大量内存(并且还需要时间来处理).
但是我并不需要一次检索所有事件.实际上我希望能够遍历列表,只读取一些事件(链接到特定的KEY_ID - sq查询myQuery按KEY_ID排序),处理它们并最终返回迭代,让垃圾收集器摆脱以前和已处理的事件,以便我永远不会超过一定的内存量.
有没有一种很好的方法可以使用Spring库(或任何库)?
干杯,Vakimshaar.
我在这里遇到一个奇怪的问题......
我有一个JUnit实现了一些测试.该类如下所示:
public class MyTest {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test
public void myTest1() throws IOException {
String destinationPath = folder.newFile("destination1.txt").getPath();
// Do things
}
@Test
public void myTest2() throws IOException {
String destinationPath = folder.newFile("destination2.txt").getPath();
// Do things
}
@Test
public void myTest3() throws IOException {
String destinationPath = folder.newFile("destination.txt").getPath();
// Do things
}
}
Run Code Online (Sandbox Code Playgroud)
这个测试类曾经在我之前的环境中工作,但仍然在Continuum中工作.
然而,当从Eclipse启动时,没有,部分或全部测试任意抛出IOException
如下:
java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)
at org.junit.rules.TemporaryFolder.newFile(TemporaryFolder.java:53)
at MyTest.myTest2(MyTest.java:50) …
Run Code Online (Sandbox Code Playgroud) 可能重复:
在Java文件中间写入字节的最佳方法
我有一个文件,我需要写入字节.
我知道文件中的哪个位置需要插入特定的字节.为了清楚起见,我需要在文件中间写入字节而不删除任何现有字节.然后整个操作应该增加文件的长度.
这样做的最佳方法是什么?
我在这里遇到一个简单的问题.我有两个属性文件我想读取来创建两个数据源.然而,那些属性文件具有完全相同的键!我可以使用以下方法读取这两个文件:
<context:property-placeholder
location="classpath:foo1.properties,classpath:foo2.properties"/>
Run Code Online (Sandbox Code Playgroud)
但后来我无法访问正确的值:
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${driver}" /> <!-- Which one? -->
<property name="url" value="${url}" /> <!-- Which one? -->
...
</bean>
Run Code Online (Sandbox Code Playgroud)
如何读取我的属性,以便我可以使用变量,如${foo1.driver}
知道哪个被调用?
谢谢你的帮助!
我试图使用Java重现以下curl命令:
curl -v -u user:pass http://myapp.com/api
Run Code Online (Sandbox Code Playgroud)
此命令返回一些JSON数据.
我的错误Java实现如下:
@Test
public void callTest() {
RestTemplate restTemplate = createRestTemplate("user", "pass");
URI uri = new URI("http://myapp.com/api");
String res = restTemplate.getForObject(uri, String.class);
}
private static RestTemplate createRestTemplate(String username, String password) {
UsernamePasswordCredentials cred = new UsernamePasswordCredentials(username, password);
BasicCredentialsProvider cp = new BasicCredentialsProvider();
cp.setCredentials(AuthScope.ANY, cred);
DefaultHttpClient client = new DefaultHttpClient();
client.setCredentialsProvider(cp);
ClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(client);
RestTemplate restTemplate = new RestTemplate(factory);
// set the media types properly
return restTemplate;
}
Run Code Online (Sandbox Code Playgroud)
然而,当我执行测试时,它返回一个org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
异常. …
java spring-mvc basic-authentication resttemplate apache-httpclient-4.x
我有以下代码:
public abstract class A<T extends B<? extends A<T>>>{
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
A other = (A) obj; // warning here: "A is a raw type"
// [...]
}
}
Run Code Online (Sandbox Code Playgroud)
如何在指定的行中避免"A是原始类型"和"类型安全:未选中的强制转换"?是否存在某种类型的黑客攻击或者我的课程出错?
谢谢
java ×8
spring ×2
apache-spark ×1
generics ×1
hibernate ×1
ioexception ×1
java-io ×1
jaxb ×1
jdbc ×1
jpa ×1
jpql ×1
junit ×1
junit4 ×1
maven ×1
resttemplate ×1
scala ×1
spring-jdbc ×1
spring-mvc ×1
sql ×1
tomcat ×1
xjc ×1