小编TS-*_*TS-的帖子

Spring @Value没有解析为属性文件中的值

之前我曾经在其他项目中工作,我只是重新做同样的事情,但由于某种原因,它不起作用.Spring @Value不是从属性文件中读取,而是从字面上理解值

AppConfig.java

@Component
public class AppConfig
{
    @Value("${key.value1}")
    private String value;

    public String getValue()
    {
        return value;
    }
}
Run Code Online (Sandbox Code Playgroud)

applicationContext.xml中:

<context:component-scan
    base-package="com.test.config" />
<context:annotation-config />

<bean id="appConfigProperties"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:appconfig.properties" />
</bean>
Run Code Online (Sandbox Code Playgroud)

appconfig.properties

key.value1=test value 1
Run Code Online (Sandbox Code Playgroud)

在我的控制器中,我有:

@Autowired
private AppConfig appConfig;
Run Code Online (Sandbox Code Playgroud)

应用程序启动很好,但是当我这样做

appConfig.getValue()
Run Code Online (Sandbox Code Playgroud)

它返回

${key.value1}
Run Code Online (Sandbox Code Playgroud)

它不会解析为属性文件中的值.

思考?

java spring spring-properties

56
推荐指数
6
解决办法
11万
查看次数

Selenium v​​s HtmlUnit?

我试图更好地理解测试框架,并一直在研究Selenium.我之前使用过HTMLUnit,主要是因为我需要从网站或类似网站上删除一些信息.

在编写测试自动化的背景下,Selenium与HTMLUnit的优点/缺点是什么?在我看来,Selenium设置比HTMLUnit更复杂,虽然同时有一个用于Selenium的HTMLUnitDriver,我认为它的行为方式与HTMLUnit本身完全相同?

Selenium显然提供了更强大的框架,它有Selenium RC用于pararel测试,它也有不同的浏览器驱动程序可以使用 - 虽然当你使用浏览器驱动程序时,测试实际上会打开/关闭浏览器应用程序而不是无头.

可能是我没有正确理解Selenium.一些方向和指针会很棒!

另一个注意事项 - 一个单独的问题 - 我也在考虑在移动浏览器上进行自动化测试,我看到Selenium有一个IPhoneDriver,但是这不是无头测试,因为它需要实际的iOS模拟器.

反正在移动网站上进行无头测试吗?更改用户代理是否足够?我已经看到一些关于改变用户代理的帖子似乎有他们自己的挑战,例如.在Selenium RC中设置用户代理

非常感谢!

selenium automated-tests htmlunit

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

基于Java的CMS,具有RESTful服务/ API以访问内容

对于那些可能因为"没有建设性而投票支持这个问题的人 - 目前看来,这个问题不适合我们的问答形式." - 如果你建议我应该在哪里发布这个问题(https://softwareengineering.stackexchange.com/?或任何以CMS为中心的论坛?)会很棒

之前曾提出过类似的问题:

所有这些都已经有几年了,所以我想知道是否有新的建议/讨论.

一些背景:我们是Java商店,我们为客户创建/维护网站,我们的技术堆栈是Java,Spring,SQL,JSP,HTML5,JQuery,Tomcat,JBoss,Maven等......通常的东西.到目前为止,就"内容"而言,我们要么将其放入JSP读取的一些属性文件中(例如产品X的描述)或提供动态内容的后端服务(例如,产品X的当前值是什么) ).

现在我们正在重新思考我们管理内容的方法,因为我们正在为具有相同内容的客户端管理越来越多的属性(例如,网站,移动网站,移动应用程序等),所以我们当然希望避免使用多个副本.相同的内容传播.

我特别想要的一些事情:

  1. 基于Java(因为我们是Java商店:1)在处理基于Java的东西方面的​​更多专业知识和2)避免在堆栈中引入另一种技术)

  2. 可扩展性/定制.需要能够自定义CMS(这就是我们希望坚持我们的Java专业知识的原因),以便可以扩展它以与其他Web服务连接以使用内容等.

  3. 专注于内容 - 我们需要明确区分内容与UI呈现,回到我们正在寻找的内容,我们需要将内容传递到单独的属性中.

  4. 用于访问内容的RESTful服务/ API - 与上述相同.我们需要将内容直接作为JSON/JSON-P /访问.XML Feed.

  5. 需要有一个像样的用户界面,并且对业务用户来说越直观越好,因为我们可能被移动到平台的一些客户可能想要管理他们自己的内容

  6. 多语言支持

  7. 开源/低成本

到目前为止,我有几个选择:

Adobe CQ - 看起来是最理想的解决方案,但不幸的是它成本过高

Hippo CMS - 看起来适合我们正在寻找的东西,我不确定它的记录有多好,教程/方法似乎相当稀少,它们在欧洲的市场份额似乎比在北美更大.

Liferay - 更加专注于"门户"而不是CMS提供内容

Alfresco - 更专注于"文件"

dotCMS - 像Hippo CMS一样,似乎这个可能符合我们的需求.

Magnolia CMS - 与dotCMS和Hippo一样环顾同一条小巷.从我看到的评论看来,他们似乎更关注单个网站,而不是内容与UI之间的清晰分离.

我个人之前没有太多直接使用CMS的经验.

您对上述每个选项的想法/意见,或者如果您有其他解决方案,请不要在此提及,我们将不胜感激!我的挑战之一是我们需要做出一个非常合理的决定,因为无论我们决定采用哪种方式,我们都可能会坚持下去,决定不是很容易被丢弃并重新开始的.

java content-management-system magnolia dotcms hippocms

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

当文件存在时,java.lang.NoClassDefFoundError

我试着四处寻找可能对我有帮助的帖子,但是找不到.

我正在为JBoss4服务器部署一个耳朵,我开始遇到这个问题,因为我添加了一个新项目.

这个新项目在eclipse中被定义为Java项目,而EAR项目有一个EJB项目,它将新的Java项目作为其依赖的项目之一 - 如果通过eclipse在本地部署在JBoss上,则没有问题,一切顺利

但是当在测试环境(eclipse之外)中部署到JBoss时,不断在新Java项目中定义的类之一上获取java.lang.NoClassDefFoundError.

我查看了EAR文件内部以获取jar(EJB项目),然后在jar中,我可以看到新Java项目中的目录结构和所有类文件 - 即.它抱怨的类就在EAR-> JAR内部,并且与它正在寻找的确切结构相匹配.

我迷失了我还能看到的其他东西.

任何指针都非常感谢!

谢谢

java jboss classnotfoundexception

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

从开发者的角度来看Sitecore

我刚开始研究Sitecore,我想知道是否有人可以帮助我从开发人员的角度来指导它是什么/如何.

我已经浏览了大量的文档以及他们的SDN - 在我看来,他们中的大多数只是通过他们的界面(即通过他们的"Sitecore桌面")进行拖放点击,只需很少的实际编程.

这是真的?或者是他们实际的C#/ ASP.Net编程背后的场景来实现业务逻辑等?

我完成了他们的基本教程(为Product创建基本站点),就像我上面提到的,它们大部分是通过他们的界面完成的,没有任何真正的编程 - 而不是使用ASP.Net MVC3音乐商店教程,你可以看到一些C#编程.

谢谢!

sitecore sitecore6

8
推荐指数
2
解决办法
5305
查看次数

maven变量属性过滤

我试图有一些变量属性值,并使用Maven配置文件来获得正确的输出.我已经为我的hibernate xml,log4j.properties做了这个,并没有问题.

所以它在项目#1中对我有用,我在/ src/main/resources下有一堆文件.我在maven中设置了属性和资源过滤,如下所示:

<properties>
    <log.level>DEBUG</log.level>
</properties>


<profiles>
    <profile>
        <id>production</id>
        <properties>
    <log.level>INFO</log.level>
        </properties>
    </profile>
</profiles>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>
Run Code Online (Sandbox Code Playgroud)

以上工作没有问题.但是,在我的项目#2中 - 我有一些具有可变属性的文件,但是它们位于/ src/main/webapp/WEB-INF下 - 我做的与上面相同,除了指向WEB-INF的目录它不起作用.我在项目#2上尝试将文件放在/ src/main/resources下并且它工作正常.

所以在我看来资源过滤有问题,当文件在/ src/main/webapp/WEB-INF下,但我需要文件在那里,所以它在生成战争时进入WEB-INF文件夹.

有没有人有关于如何做到这一点的指针?

以下是pom.xml中的以下snipet不起作用(资源过滤完全被忽略)

<properties>
        <wsdl.url>http://stage/wsdl-url</wsdl.url>
</properties>

<profiles>
    <profile>
        <id>production</id>
        <properties>
    <wsdl.url>http://prod/wsdl-url</wsdl.url>
        </properties>
    </profile>
</profiles>

<build>
    <resources>
        <resource>
            <directory>src/main/webapp/WEB-INF</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>
Run Code Online (Sandbox Code Playgroud)

maven maven-profiles

6
推荐指数
1
解决办法
3931
查看次数

调用WebService并出现SSL /证书问题

我将首先介绍一下我在Java中设置密钥库等方面的知识并不多

我正在尝试调用SOAP Web服务,我得到了wsdl,生成了代码等等.在我部署它并尝试触发WS调用之前,一切似乎都没问题.

这是我的设置:

  • Tomcat 7.0.35
  • Java,jdk 1.6.0_39
  • pfx文件和密码
  • 项目作为标准Web应用程序(战争)部署到tomcat

当我运行代码时,我得到以下异常:

Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking https://tallyservices-qa.olson.com/tallyDemo2WebServices/tallyDemo2/sms: Received fatal alert: certificate_unknown
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1336)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1320)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    ... 27 more
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1837)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1019)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1203)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1230)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1214)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.setupWrappedStream(URLConnectionHTTPConduit.java:170)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1280)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1231)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.onFirstWrite(URLConnectionHTTPConduit.java:183) …
Run Code Online (Sandbox Code Playgroud)

java tomcat soap

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

@Secured函数获取授权用户的拒绝访问权限

我已经按照很多线程将Spring Security实现到我的rest API.最初我被卡在@Secured注释被忽略,现在我已经解决了,我被困在获得拒绝访问.

感觉像我的问题听起来非常相似:@secured与授权的权限抛出访问被拒绝的异常 - 但我仍然被拒绝访问.

这是我的设置:

弹簧security.xml文件

<authentication-manager>
    <authentication-provider user-service-ref="userDetailsService">
        <password-encoder ref="passwordEncoder" />
    </authentication-provider>
</authentication-manager>

<beans:bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.PlaintextPasswordEncoder"/>

<user-service id="userDetailsService">
    <user name="john" password="john1" authorities="ROLE_USER, ROLE_ADMIN" />
    <user name="jane" password="jane1" authorities="ROLE_USER" />
    <user name="apiuser" password="apiuser" authorities="PERMISSION_TEST" />
</user-service>
Run Code Online (Sandbox Code Playgroud)

控制器:

@Controller
@RequestMapping("/secure")
public class SecureController
{
    private static final Logger logger = Logger.getLogger(SecureController.class);

    @Secured("PERMISSION_TEST")
    @RequestMapping(value = "/makeRequest", method = RequestMethod.GET)
    @ResponseBody
    public SimpleDTO executeSecureCall()
    {
        logger.debug("[executeSecureCall] Received request to a secure method");

        SimpleDTO dto = new SimpleDTO();
        dto.setStringVariable("You are …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security

6
推荐指数
2
解决办法
4299
查看次数

Sonar安装并启动但无法访问

摘要:


我想在运行CentOS 6.5的远程机器上运行一个独立的声纳.

以下:http://sonar-pkg.sourceforge.net/ - 通过以下方式安装:

yum install sonar
Run Code Online (Sandbox Code Playgroud)

我已经建立了一个与MySQL实例的远程数据库连接,已经设置了'sonar'数据库和用户,如下所述:http://docs.sonarqube.org/display/SONAR/Installing

修改sonar.properties配置:

sonar.jdbc.url=jdbc:mysql://<mysql.ipaddress>:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
Run Code Online (Sandbox Code Playgroud)

最初 - 我只改变了jdbc连接,声纳开始很好,但我无法打开声纳网页http://mymachine.ipaddress:9000 /

基于:

我更新了更多属性:

sonar.web.host=<mymachine.ipaddress>
sonar.web.context=/sonar
sonar.web.port=9000
Run Code Online (Sandbox Code Playgroud)

并再次运行声纳

/etc/init.d/sonar start
Run Code Online (Sandbox Code Playgroud)

Sonar很好,但仍然无法通过浏览器访问它.
转到http://mymachine.ipaddress:9000 /声纳给出:"此网页不可用"

GET http://mymachine.ipaddress:9000/sonar net::ERR_CONNECTION_TIMED_OUT 
Run Code Online (Sandbox Code Playgroud)

sonar.log:

- > Wrapper开始作为守护进程启动JVM ... Wrapper(版本3.2.3)http://wrapper.tanukisoftware.org 版权所有1999-2006 Tanuki Software,Inc.保留所有权利.

2014.10.01 14:30:18 INFO app [ospmJavaProcessLauncher]启动流程[搜索]:/ usr/lib/jvm/java-1.7.0-openjdk-1.7.0.55.x86_64/jre/bin/java -Xmx256m -Xms256m - Xss256k -Djava.net.preferIPv4Stack = true -XX:+ UseParNewGC -XX:+ …

sonarqube

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

maven-ear-plugin和JBoss AS 7

我正在迁移到JBoss AS 7,并使用maven build,在我看来maven-ear-plugin还不支持JBoss AS 7.默认情况下,它使用JBoss AS 4.

这会导致问题吗?

我还在努力弄清楚如何构建我的档案,现在有与JBoss AS 7类加载器工作方式的变化有关的问题.

migration maven jboss7.x maven-ear-plugin

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

添加图片F#

我有一个堆栈面板,我想动态添加一些图标.

如果我将一个TextBlock添加到堆栈面板,它可以完美地工作:

// assuming stackPanel is my stack panel
let text = new TextBlock()
text.Text <- "Test"
stackPanel.Children.add(text)
Run Code Online (Sandbox Code Playgroud)

但是,我的目标是添加图像,但似乎无法解析图像

let getImageSource(imagePath) = 
    let uri = new Uri(imagePath, UriKind.Relative)
    new BitmapImage(uri); 

let icon = new Image()
icon.Source <- getImageSource("images/fileIcon/icon.gif")

stackPanel.Children.Add(icon) // this doesnt work
Run Code Online (Sandbox Code Playgroud)

现在我做的时候:

let icon = new Image()
icon.Source <- getImageSource("images/fileIcon/icon.gif")

stackPanel.Children.Add(icon) 

let text = new TextBlock()
text.Text <- "Test"
stackPanel.Children.add(text)
Run Code Online (Sandbox Code Playgroud)

我可以看到文本之间有一个空白区域,好像那里有一个空图像.所以我的猜测是我解决图像路径的方式有问题 - 但我不确定原因.

思考?

谢谢!

silverlight f#

3
推荐指数
1
解决办法
402
查看次数

帮助F#:"收集被修改"

我对F#很新,我遇到了F#中的"Collection was modified"问题.我知道当我们在同时修改(添加/删除)它时迭代Collection时,这个问题很常见.stackoverflow中的先前线程也指向此.

但就我而言,我正在开发两套不同的产品:我有两个系列:

  • originalCollection原始集合,我想从中删除东西
  • colToRemove包含我要删除的对象的集合

以下是代码:

   Seq.iter ( fun input -> ignore <| originalCollection.Remove(input)) colToRemove
Run Code Online (Sandbox Code Playgroud)

我收到以下运行时错误:+ $ exception {System.InvalidOperationException:Collection已被修改; 枚举操作可能无法执行. System.ChrowHelper.ThrowInvalidOperationException(ExceptionResource资源)位于System.Collections.Generic.List 1.Enumerator.MoveNextRare() at System.Collections.Generic.List1.Enumerator.MoveNext()at Microsoft.FSharp.Collections.IEnumerator.next@174 [T](FSharpFunc 2 f, IEnumerator1 e,FSharpRef 1 started, Unit unitVar0) at Microsoft.FSharp.Collections.IEnumerator.filter@169.System-Collections-IEnumerator-MoveNext() at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc2 action,IEnumerable `1来源)

这是代码块:

        match newCollection with
        | Some(newCollection) ->

            // compare newCollection to originalCollection.
            // If there are things that exist in the originalCollection that are not in the newCollection, we want to remove them
            let …
Run Code Online (Sandbox Code Playgroud)

f#

1
推荐指数
1
解决办法
273
查看次数

Spring @Transaction在抛出Exception时不回滚

我一直在寻找这个问题,在StackOverflow和Google上有很多这样的问题,但我似乎无法为我工作.

这是我的代码Spring配置:(我不使用任何切入点 - 我想我不需要?)

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
...
</bean>

<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
 <property name="dataSource" ref="dataSource" />
 ...
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="hibernateSessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
Run Code Online (Sandbox Code Playgroud)

我有一个服务类:

@Service
public class ServiceImpl implements ServiceInterface 
{
    /**
     * Injected session factory
     */
    @Autowired(required=true)
    private SessionFactory sessionFactory;

    @Autowired(required=true)
    private Dao myDao;

    /**
     * {@inheritDoc}
     */
    @Transactional(rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
    public void scheduleBlast(BlastParameters blastParameters) throws ServiceException 
    {
        ... do bunch of stuff ..
        myDao.persist(entity)

        if(true)
            throw new ServiceException("random error")
    }

    .. setter methods and …
Run Code Online (Sandbox Code Playgroud)

java hibernate spring-3

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