小编Ale*_*ian的帖子

使用Tomcat在Eclipse中运行Web服务时出现相同路径错误的多个上下文

这是我使用Eclipse创建第一个Axis2 Web服务时遇到的错误.在我编写类之后,我使用Apache Axis2创建了Web服务.当我在eclipse中单击启动服务器按钮时,它会显示一条错误消息:

无法在localhost上发布Tomcat v6.0 Server的服务器配置.
多个上下文的路径为"/ FirstApache".

FirstApache是​​我之前创建的动态Web项目.我从Web服务向导的配置部分中选择了正确的Web项目.

我怎样才能解决这个问题?

eclipse axis tomcat web-services

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

javascript中的QR码生成库

我目前正在寻找一个可以在qr代码中编码文本的js库.到目前为止,我能找到的唯一一个看起来很破旧,尽管其他人声称正在使用它.示例页面不起作用.通过播放它,我设法生成代码,但它们不会被手机软件解码.

还有另一个库是js吗?有没有人设法让它工作?

我对从在线服务(kaywa,google等)中提取代码的解决方案不感兴趣.


更新:

嗯,你们是对的,那个图书馆确实有用.我的问题是我尝试将它包含在HTML5 Boilerplate页面中,而document.write似乎不起作用.无论如何我修改了示例代码,使浏览器在画布而不是表格中绘制,我向后获得了fillRect函数的顺序.以下是更正后的函数调用.

context.fillRect(c * UNIT_SIZE, r * UNIT_SIZE, UNIT_SIZE, UNIT_SIZE);
// it's column-row, not row-column; don't ask why :)
Run Code Online (Sandbox Code Playgroud)

因为我不再让我的图像转换:),现在qr解码很好.感谢您的支持.

javascript qr-code

57
推荐指数
4
解决办法
7万
查看次数

如何将依赖项的测试jar包含到Maven项目的部署中?

我有两个项目,foofoo-web在该com.example组下.foo-web取决于foo.

为了能够在不依赖外部服务的情况下开发应用程序的UI部分,实现了虚拟DAO foo(它们返回静态数据,因此我们不必连接到数据库等).

我们被要求将虚拟类移动到src/test/java.这意味着它们不会部署foo.jar到从Web项目构建的战争中.我在maven网站上找到了这些说明,但它们似乎对我不起作用.

foopom.xml,我有:

        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <executions>
            <execution>
              <id>test-jar</id>
              <phase>test-compile</phase>
              <goals>
                <goal>test-jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

在跑步mvn install的时候foo-web,在foo我的目标中我会得到两个罐子:foo-1.0.0-SNAPSHOT.jarfoo-1.0.0-SNAPSHOT-tests.jar.它们都在本地maven存储库中安装得很好.

以前,foo-web依赖关系看起来像这样:

<dependency>
    <groupId>com.example</groupId>
    <artifactId>foo</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这将触发foo-1.0.0-SNAPSHOT.jar战争中的部署.现在,我想部署-testsjar,最好只用于"本地"配置文件.

我尝试过各种方法来做到这一点:

<profile>
    <id>local</id>
    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>foo</artifactId>
            <version>1.0.0-SNAPSHOT</version>
            <type>test-jar</type>
        </dependency>
    </dependencies>
</profile>
Run Code Online (Sandbox Code Playgroud)

这会导致使用不同的名称部署源jar:com.example-foo.jar并且不部署测试jar.我也尝试使用<classifier>而不是 …

java deployment dependencies maven

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

JavaScript主机对象是如何实现的?

今天我在想这个,我意识到我这里没有清晰的图片.

以下是我认为是真实的一些陈述(如果我错了,请纠正我):

  • DOM是W3C指定的接口集合.
  • 在解析HTML源代码时,浏览器会创建一个DOM树,其中包含实现DOM接口的节点.
  • ECMAScript规范没有引用浏览器主机对象(DOM,BOM,HTML5 API等).
  • 实际实现DOM的方式取决于浏览器的内部结构,并且在大多数情况下可能不同.
  • 现代JS解释器使用JIT来提高代码性能并将其转换为字节码

我很好奇我打电话后幕后发生的事情document.getElementById('foo').调用是否由解释器委托给浏览器本机代码,或者浏览器是否具有所有主机对象的JS实现?你知道他们对此做了什么优化吗?

我阅读了浏览器内部的这个概述,但它没有提到任何关于这个的内容.我有空的时候会浏览Chrome和FF源码,但我想先问一下这里.:)

javascript browser dom

27
推荐指数
3
解决办法
1415
查看次数

在Spring bean上下文中声明一个对象数组

我正在尝试在Spring上下文文件中创建一个对象数组,因此我可以将它注入一个声明如下的构造函数:

public RandomGeocodingService(GeocodingService... services) { }
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用<array>标签:

<bean id="googleGeocodingService" class="geocoding.GoogleGeocodingService">
 <constructor-arg ref="proxy" />
 <constructor-arg value="" />
</bean>

<bean id="geocodingService" class="geocoding.RandomGeocodingService">
    <constructor-arg>
        <array value-type="geocoding.GeocodingService">
            <!-- How do I reference the google geocoding service here? -->
        </array>
    </constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)

我无法在文档中找到有关如何执行此操作的示例或内容.此外,你有任何建议,以更好的方式来实现我正在尝试做的事情,请让我知道:).

java spring javabeans

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

JDK Locale类处理希伯来语(他),意第绪语(yi)和印度尼西亚语(id)的ISO语言代码

当实例化一个Locale用以下语言代码的任一对象:he,yi并且id它不保留自己的价值.

例如:

Locale locale = new Locale("he", "il");
locale.getLanguage(); // -> "iw"
Run Code Online (Sandbox Code Playgroud)

造成这种情况的原因是什么方法可以解决这个问题?

java locale

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

单元测试使用Spring JDBC的DAO类

我有几个DAO对象用于从数据库中检索信息,我真的想为它们编写一些自动化测试,但我很难弄清楚如何去做.

我正在使用Spring JdbcTemplate来运行实际查询(通过预准备语句)并将结果映射到模型对象(通过RowMapper类).

如果我要编写单元测试,我不确定如何/应该模拟对象.例如,由于只有读取,我会使用实际的数据库连接而不是模拟jdbcTemplate,但我不确定是否正确.

这是批次中最简单的DAO的(简化)代码:

/**
 * Implementation of the {@link BusinessSegmentDAO} interface using JDBC.
 */
public class GPLBusinessSegmentDAO implements BusinessSegmentDAO {
    private JdbcTemplate jdbcTemplate;

    private static class BusinessSegmentRowMapper implements RowMapper<BusinessSegment>  {
        public BusinessSegment mapRow(ResultSet rs, int arg1) throws SQLException { 
            try {
                return new BusinessSegment(rs.getString(...));
            } catch (SQLException e) {
                return null;
            }
        }
    }

    private static class GetBusinessSegmentsPreparedStatementCreator 
        implements PreparedStatementCreator {
        private String region, cc, ll;
        private int regionId;

        private GetBusinessSegmentsPreparedStatementCreator(String cc, String …
Run Code Online (Sandbox Code Playgroud)

java testing spring dao jdbctemplate

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

在Visual Studio 2010中使用扩展对象调试XSLT

我目前正在开发一个涉及大量XSLT转换的项目,我真的需要一个调试器(我有1000多行的XSLT ,我没有写它们:-).

该项目是用C#编写的,并使用扩展对象:

xslArg.AddExtensionObject("urn:<obj>", new <Obj>());
Run Code Online (Sandbox Code Playgroud)

据我所知,在这种情况下,Visual Studio是唯一可以帮助我逐步调试转换的工具.由于扩展对象,静态调试器没有用处(当它到达引用其命名空间的元素时会抛出错误).幸运的是,我发现这个线程给了我一个起点(至少我知道它可以完成).

在搜索MSDN之后,我找到了可以进入转换的标准.它们列在这里.简而言之:

  • 必须通过具有IXmlLineInfo接口(XmlReader&co.)的类加载XML和XSLT
  • XSLTCompiledTransform构造函数中使用的XML解析器是基于文件的(XmlUriResolver应该可以工作).
  • 样式表应该在本地机器上或内部网上(?)

据我所知,我符合所有这些标准,但它仍然无效.相关代码示例发布如下:

// [...]

xslTransform = new XslCompiledTransform(true);

xslTransform.Load(XmlReader.Create(new StringReader(contents)), null, new BaseUriXmlResolver(xslLocalPath));

// [...]

// I already had the xml loaded in an xmlDocument 
// so I have to convert to an XmlReader
XmlTextReader r = new XmlTextReader(new StringReader(xmlDoc.OuterXml));

XsltArgumentList xslArg = new XsltArgumentList();
xslArg.AddExtensionObject("urn:[...]", new [...]());
xslTransform.Transform(r, xslArg, context.Response.Output);
Run Code Online (Sandbox Code Playgroud)

我真的不明白我做错了什么.我检查了两个XmlReader对象上的接口,然后实现了所需的接口.此外,BaseUriXmlResolver继承自 …

c# xslt debugging visual-studio extension-objects

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

Java中的静态初始化器和静态方法

在Java中调用类上的静态方法是否会触发静态初始化块来执行?

根据经验,我会说不.我有这样的事情:

public class Country {
    static {
        init();
        List<Country> countries = DataSource.read(...); // get from a DAO
        addCountries(countries);
    }

    private static Map<String, Country> allCountries = null;

    private static void init() {
        allCountries = new HashMap<String, Country>();
    }

    private static void addCountries(List<Country> countries) {
        for (Country country : countries) {
            if ((country.getISO() != null) && (country.getISO().length() > 0)) {
                allCountries.put(country.getISO(), country);
            }
        }
    }

    public static Country findByISO(String cc) {
        return allCountries.get(cc);
    }
}
Run Code Online (Sandbox Code Playgroud)

在使用该类的代码中,我执行以下操作:

Country country = Country.findByISO("RO");
Run Code Online (Sandbox Code Playgroud)

问题是我得到了一个 …

java static initialization

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

Maven - 使用JDK 7编译JVM 5

我一直试图让它工作一段时间,但还没有运气.

我想JAVA_HOME指向JDK7但是我想为JVM 5编译一个项目.我已经阅读了文档,我在SO上发现了类似的帖子,但它们似乎都没有在我的设置中工作.

我首先尝试设置target,source但我收到了一个错误:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.5</source>
        <target>1.5</target>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

[ClassName]不是抽象的,不重写抽象方法getParentLogger()CommonDataSource

据我所知,在JDK 7中更新了类,并且添加了抛出错误的额外方法.我需要使用具有旧实现的JDK 5的运行时,一切都应该正常工作.所以我这样做:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <verbose>true</verbose>
        <source>1.5</source>
        <target>1.5</target>
        <compilerArguments>
            <bootclasspath>${env.JAVA5_HOME}/jre/lib/rt.jar</bootclasspath>
        </compilerArguments>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我在我的系统上正确设置了JAVA5_HOME,我可以看到它在日志中加载了正确的类,但是我遇到了另一个错误:

[loading ZipFileIndexFileObject[c:\Program Files\Java\jdk1.5.0_22\jre\lib\rt.jar(*.class)]]
...
...
[ClassName]错误:包javax.crypto不存在

这是公平的,因为我没有包括jce.jar(加密类)bootclasspath.但是有一件事让我感到困惑.即使bootclasspath只包含Java 5运行时,我在类路径中有很多来自JRE7的库.它们没有在任何地方指定.

[类文件的搜索路径:c:\ Program Files(x86)\ Java\jdk1.5.0_22\jre\lib\rt.jar,c:\ Program Files\Java\jdk1.7.0_02\jre\lib\ext\dnsns.jar,c:\ Program Files\Java\jdk1.7.0_02\jre\lib\ext\localedata.jar,c:\ Program Files\Java\jdk1.7.0_02\jre\lib\ext\sunec.jar, c:\ Program Files\Java\jdk1.7.0_02\jre\lib\ext\sunjce_provider.jar,c:\ Program Files\Java\jdk1.7.0_02\jre\lib\ext\sunmscapi.jar,c:\ Program Files\Java\jdk1.7.0_02\jre\lib\ext\zipfs.jar,...]

如果我尝试添加jce.jar(来自JRE5),我会回到第一个错误:

<plugin>
    <groupId>org.apache.maven.plugins</groupId> …
Run Code Online (Sandbox Code Playgroud)

java jdk1.5 maven

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