小编cmd*_*cmd的帖子

无法解析字符串值中的占位符

我试图使用.properties文件中的属性,但它似乎不起作用.

这是我的代码:

@Service("ServiceFTP")
@Transactional
public class ServiceFTPImpl implements ServiceFTP {

@Value("${project.ftp.adresse}")
private String adresse;

@Value("${project.ftp.login}")
private String compte;

@Value("${project.ftp.password}")
private String motDePasse;

@Value("${project.ftp.root}")
private String ROOT;

[...]

}
Run Code Online (Sandbox Code Playgroud)

此类使用@Value注释来获取属性.它也被声明为Spring Service并链接到我的infraContext.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">

<context:property-placeholder location="classpath:context-core.properties"/>

[...]

</beans>
Run Code Online (Sandbox Code Playgroud)

使用context:property-placeholder,我将此文件链接到我的context-core.properties文件:

project.ftp.adresse = localhost
project.ftp.login = anonymous
project.ftp.password =
project.ftp.root = /anonymous/
Run Code Online (Sandbox Code Playgroud)

这确实有道理,对吗?

但是当我尝试启动我的项目时,Tomcat抛出了这个异常:

    ERROR [context.ContextLoader.initWebApplicationContext()] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name …
Run Code Online (Sandbox Code Playgroud)

java spring

71
推荐指数
6
解决办法
24万
查看次数

如何检查目录是否是另一个目录的子目录

我喜欢用Python编写一个模板系统,它允许包含文件.

例如

    This is a template
    You can safely include files with safe_include`othertemplate.rst`

如您所知,包含文件可能很危险.例如,如果我在允许用户创建自己的模板的Web应用程序中使用模板系统,他们可能会做类似的事情

I want your passwords: safe_include`/etc/password`

因此,我必须限制将文件包含在例如某个子目录中的文件中(例如/home/user/templates)

现在的问题是:我如何检查,是否/home/user/templates/includes/inc1.rst在子目录中/home/user/templates

以下代码是否有效且安全?

import os.path

def in_directory(file, directory, allow_symlink = False):
    #make both absolute    
    directory = os.path.abspath(directory)
    file = os.path.abspath(file)

    #check whether file is a symbolic link, if yes, return false if they are not allowed
    if not allow_symlink and os.path.islink(file):
        return False

    #return true, if the common prefix of both is equal to directory …
Run Code Online (Sandbox Code Playgroud)

python filesystems security validation

38
推荐指数
7
解决办法
3万
查看次数

Sublime Text 2 - 打开文件夹

是否可以使用Sublime Text 2在同一窗口中打开多个文件夹?

选择File->Open Folder始终在新窗口中打开文件夹.

Sublime Text是一个出色的编辑器,但这个问题有点烦人.

editor sublimetext sublimetext2

33
推荐指数
2
解决办法
4万
查看次数

使用JAX-RS的REST - 处理长时间运行的操作

我有一个用JAX-RS实现的REST服务.有些操作需要很长时间才能完成,可能需要15-30分钟.对于这些情况,我倾向于派遣后台线程来处理长时间运行的操作,然后立即响应HTTP状态202 ACCEPTED.响应将包含一个带有URL的位置标头,客户端可以使用该标头来轮询进度.

这种方法需要创建线程来处理长时间运行的操作,这样就可以立即返回202 ACCEPTED.我也知道在Java EE容器中创建自己的线程通常是不好的做法!

我的问题如下:

  1. 人们都同意这是一种正确的方法吗?
  2. 假设它是正确的,人们可以推荐一个"良好实践"解决方案,使我能够在后台调度长时间运行并立即返回吗?

另外,为了避免管理我自己的线程,我查看了JAX-RS异步服务器api.不幸的是,虽然这提高了服务器吞吐量,但它不允许我立即响应ACCEPTED.

泽西州声明如下:

Note that the use of server-side asynchronous processing model will not improve the 
request processing time perceived by the client. It will however increase the
throughput of the server, by releasing the initial request processing thread back to
the I/O container while the request may still be waiting in a queue for processing or    
the processing may still be running on another dedicated thread. The released I/O  
container thread can …
Run Code Online (Sandbox Code Playgroud)

java rest multithreading jax-rs jersey

14
推荐指数
2
解决办法
7831
查看次数

Java已启动,但返回退出代码= 13 eclipse

我看了所有其他地方,我无法弄清楚如何做到这一点.

你如何键入java -version控制台.因为我所得到的只是java不被识别为命令.

我去了java网站,我得到了1.7.0_45版本

所以我这样做了

C:\ Program Files(x86)\ Java\jdk1.7.0_45\bin\javaw.exe

代替

C:\ Program Files(x86)\ Java\jre7\bin\javaw.exe

它也没用

"C:\ Program Files(x86)\ Java\jre7\bin\java.exe"-1.7.0_45

它也没用.

sdk已从官方网站下载了10月30日的最新android .救命?

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-product
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
256M
-showsplash
com.android.ide.eclipse.adt.package.product
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm C:\Program Files (x86)\Java\jre7\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40
-Xmx768m
-Declipse.buildId=v22.3.0-887826
-XX:MaxPermSize=512M
Run Code Online (Sandbox Code Playgroud)

java eclipse android

14
推荐指数
1
解决办法
4万
查看次数

没有名为X的EntityManager的持久性提供程序

我正在使用JPA开发JavaSE应用程序.不幸的是,我null打电话后: Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);

您将在下面找到:

  • 我的代码片段,调用EntityManagerFactory并意外返回null
  • 我的persistence.xml档案
  • 我的项目结构

我的代码片段:

public class Main {
    private static final String PERSISTENCE_UNIT_NAME = "MeineJpaPU";
    private static EntityManagerFactory factory;

    public static void main(String[] args) {
        // I get null on this line!!!
       factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);

       EntityManager em = factory.createEntityManager();
       // do stuff with entity manager
       ...
    }
}
Run Code Online (Sandbox Code Playgroud)

我的persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
    xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
                        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
  <persistence-unit name="MeineJpaPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <class>path.to.package.server.Todo</class>
      <exclude-unlisted-classes>false</exclude-unlisted-classes>
     <properties>       
            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>       
            <property name="javax.persistence.jdbc.url" …
Run Code Online (Sandbox Code Playgroud)

java jpa entitymanager persistence.xml java-ee

13
推荐指数
2
解决办法
7万
查看次数

性能/压力测试Java EE应用程序

仅使用单元测试很难在Java应用程序中找到所有瓶颈,死锁和内存泄漏.

我想为我的应用程序添加一些级别的压力测试.我想测试应用程序的限制并确定它在高负载下的反应.

我想评估以下内容:

  • 高负荷下的可用性
  • 高负荷下的性能
  • 高负载下的内存/ CPU /磁盘使用情况
  • 它是否在高负载下崩溃或正常反应

在正常载荷下测量和对比这些特征也是有趣的.

是他们众所周知的标准技术,以解决压力测试.我正在寻找建立这样一个环境的帮助/方向.理想情况下,我希望定期运行这些测试,以便我们可以确定最近的交付是否会影响性能.

java testing load-testing performance-testing java-ee

12
推荐指数
2
解决办法
1万
查看次数

如何使用命令行将多个项目导入Eclipse?

反正我是否可以使用命令行将多个项目一次性导入Eclipse工作区?我注意到有人建议使用命令行如下:

eclipse -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -importAll {[uri:/]/path/to/project}

但是我无法正确地找出{[uri:/]/path/to/project}部分.任何例子?另外,上面的命令行是我能实现这一目标的唯一方法吗?(它似乎依赖于CDT?)有没有其他方法可以在命令行中执行此操作?

谢谢!

eclipse import eclipse-cdt

9
推荐指数
2
解决办法
8184
查看次数

JPA + Hibernate:如何定义具有ON DELETE CASCADE的约束

我只是想知道是否有这样一种方法可以构建我的MySQL表格

ALTER TABLE `USERINFO`
  ADD CONSTRAINT `FK_USER_ID` FOREIGN KEY (`USERID`) REFERENCES `USERACCOUNT` (`USERID`) 
    ON DELETE CASCADE 
    ON UPDATE CASCADE;
Run Code Online (Sandbox Code Playgroud)

但是,当hibernate ++ jpa开始构建我的表时,我只在我的DDL中得到了这个<property name="hibernate.hbm2ddl.auto" value="create" />"

ALTER TABLE `USERINFO` ADD CONSTRAINT `FK_USER_ID` FOREIGN KEY (`USERID`) REFERENCES `USERACCOUNT` (`USERID`);
Run Code Online (Sandbox Code Playgroud)

在我的课程中,我有这些注释设置,

// UserAcc.java
@Entity
@Table(name = "USERACC")
public class UserAcc implements Serializable {

private static final long serialVersionUID = -5527566248002296042L;

@Id
@Column(name = "USERID")
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer userId;


@OneToOne(mappedBy = "userAcc")
private UserInfo userInfo;
....


public UserInfo getUserInfo() {
    return userInfo; …
Run Code Online (Sandbox Code Playgroud)

java mysql hibernate jpa cascade

9
推荐指数
2
解决办法
2万
查看次数

我可以在eclipse中的包内创建文件夹吗?

我有项目,源文件夹为“app”,在这个包中我有包“models”。我可以在此包中创建文件夹或任何其他类型的子目录吗?所以最终我会得到类似的东西

-app
   -models
       -Folder1
           -file1
           -file2
       -Folder2
           -file3
           -file4
Run Code Online (Sandbox Code Playgroud)

当我尝试强制在内部创建文件夹(通过单击“新建”->“其他”->“文件夹”)时,我无法向其中添加任何内容。

java eclipse

5
推荐指数
1
解决办法
2万
查看次数