小编Bet*_*sta的帖子

Servlet 3.0 API的Maven依赖?

如何告诉Maven 2加载Servlet 3.0 API?

我试过了:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>3.0</version>
    <scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我使用http://repository.jboss.com/maven2/但是哪个存储库是正确的?

附录:

它适用于整个Java EE 6 API的依赖项和以下设置:

<repository>
    <id>java.net</id>
    <url>http://download.java.net/maven/2</url>
</repository>

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我更愿意只将Servlet API添加为依赖项,但"Brabster"可能是正确的,Java EE 6配置文件已替换了单独的依赖项.是否有来源证实了这一假设?

java maven-2 servlets java-ee

227
推荐指数
7
解决办法
25万
查看次数

Git Shelve vs Stash

shelve对Git 的方面非常不熟悉.如果stash用来放弃未完成的工作shelve那么呢?你会用它做什么用的?

git intellij-idea

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

如何在Spring中定义List bean?

我正在使用Spring在我的应用程序中定义阶段.它被配置为必要的类(这里称为Configurator)注入阶段.
现在我需要另一个名为的阶段列表LoginBean.在Configurator不提供访问其阶段的名单.

我不能改变班级Configurator.

我的想法:
定义一个名为Stages的新bean并将其注入ConfiguratorLoginBean.我的这个想法的问题是我不知道如何转换这个属性:

<property ...>
  <list>
    <bean ... >...</bean>
    <bean ... >...</bean>
    <bean ... >...</bean>
  </list>
</property>
Run Code Online (Sandbox Code Playgroud)

成豆.

这样的东西不起作用:

<bean id="stages" class="java.util.ArrayList">
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我吗?

java spring

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

如何配置Logback以将记录器的不同级别记录到不同的目标?

如何配置Logback以将记录器的不同级别记录到不同的目标?

例如,给定以下Logback配置,Logback会将INFO消息记录到STDOUTERROR消息STDERR吗?

(请注意,此示例是第3章:Logback配置中logback-examples/src/main/java/chapters/configuration/sample4.xml显示的示例的变体).

<configuration>
  <appender name="STDOUT"
   class="ch.qos.logback.core.ConsoleAppender">
   <encoder>
     <pattern>
        %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
      </pattern>
    </encoder>
  </appender>
  <appender name="STDERR"
   class="ch.qos.logback.core.ConsoleAppender">
   <encoder>
     <pattern>
        %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
      </pattern>
    </encoder>
    <target>System.err</target>
  </appender>
  <!-- What is the effective level of "chapters.configuration"? -->
  <logger name="chapters.configuration" level="INFO" additivity="false">
    <appender-ref ref="STDOUT" />
  </logger>
  <logger name="chapters.configuration" level="ERROR" additivity="false">
    <appender-ref ref="STDERR" />
  </logger>

  <!-- turn OFF all logging (children can override) --> …
Run Code Online (Sandbox Code Playgroud)

java logging logback

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

匹配的通配符是严格的,但是找不到元素'context:component-scan的声明

我在尝试第一个春季项目时遇到以下错误:

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan
Run Code Online (Sandbox Code Playgroud)

这是applicationContext.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:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

        <context:component-scan base-package="com.xyz" />

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

是什么导致错误?

java spring

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

Maven更新POM中的依赖项

是否有任何预先存在的Maven插件或命令来更新POM中的依赖项?示例:(如果这是在我的POM中)

<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.3</version>
</dependency> 
Run Code Online (Sandbox Code Playgroud)

是否有一个命令或插件我可以运行以使其更新依赖项:

<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.4</version>
</dependency> 
Run Code Online (Sandbox Code Playgroud)

java plugins command maven-2

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

滚动日志记录文件大小和时间

我一直在尝试设置一个简单的logback项目来按日期和文件大小滚动我的日志文件,到目前为止,我一直无法让我的appender转到另一个文件.而是写入<file />标记指定的日志.

这是我的logback.xml配置文件:

<?xml version="1.0"?>
<configuration scan="true" scanPeriod="10 seconds">
    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
        </layout>
    </appender>

    <appender name="milliroller" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>log/output.log</file>
        <layout class="ch.qos.logback.classic.PatternLayout">
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
        </layout>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>log/mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>1KB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>
    </appender>

    <root level="DEBUG">
        <appender-ref ref="stdout"/>
        <appender-ref ref="milliroller"/>
    </root>

    <logger name="com.tkassembled.logback" level="DEBUG"/>
</configuration>
Run Code Online (Sandbox Code Playgroud)

乍一看,它看起来应该有效,对吗?有什么我做错了吗?我的整个可构建项目都可以在这里找到:http://www.mediafire.com/file/2bxokkdyz2i/logback.zip

java logging logback

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

神秘的Eclipse JSP验证错误

Eclipse(Helios)偶尔会将有效的JSP内容标记为有错误.当我使用<c:if>标签时,它似乎经常会中断.例如,在仅包含此内容的JSP中:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>

<c:if test="${1 == 1}">
something
</c:if>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

编译后,"问题"选项卡中显示以下错误:

  • 不兼容的操作数类型String和int第1行
  • 无法将javax.servlet.jsp.JspException解析为类型行1
  • javax.servlet.jsp.PageContext无法解析为类型行1

代码运行正常.对JSP的验证是否有问题,我是否遗漏了一些明显的问题,或者这表明某些内容未正确设置.

java eclipse validation jsp

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

Spring @Async不工作

一个@Async在方法@Service-annotated类不被异步调用-它阻塞线程.

我已经进入<task: annotation-driven />了我的配置,并且对该方法的调用来自于类外部,因此代理应该被命中.当我单步执行代码时,代理确实被命中,但它似乎没有任何与任务执行器中运行相关的任何类.

我已经把断点放进去AsyncExecutionInterceptor,他们永远不会受到打击.我调试过AsyncAnnotationBeanPostProcessor,可以看到建议应用.

该服务被定义为一个接口(该方法@Async在那里注释以获得良好的衡量标准),实现的方法也被注释@Async.两者都没有标记@Transactional.

什么想法可能出错了?

- = UPDATE = -

奇怪的是,它只有task在我的app-servlet.xml文件中有我的XML元素时才有效,而不是在我的app-services.xml文件中,如果我也从那里对服务进行组件扫描.通常我有一个只包含控制器的XML文件(并相应地限制组件扫描),另一个包含服务(同样限制了组件扫描,使得它不会重新扫描另一个加载的控制器)文件).

APP-servlet.xml中

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:jee="http://www.springframework.org/schema/jee" 
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:webflow="http://www.springframework.org/schema/webflow-config" 
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/task
    http://www.springframework.org/schema/task/spring-task-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/jee 
    http://www.springframework.org/schema/jee/spring-jee-3.0.xsd"
>
<task:annotation-driven executor="executor" />
<task:executor id="executor" pool-size="7"/>

<!-- Enable controller annotations -->
<context:component-scan base-package="com.package.store">
    <!-- <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> -->
</context:component-scan>

<tx:annotation-driven/>
<bean id="transactionManager" …
Run Code Online (Sandbox Code Playgroud)

java spring asynchronous

44
推荐指数
6
解决办法
7万
查看次数

Log4j:为什么根记录器收集所有日志类型而不管配置如何?

我有问题,即使我在根标签中指定ERROR级别,指定的appender会将所有级别(debug,info,warn)记录到文件中,而不管设置如何.我不是log4j专家,所以任何帮助表示赞赏.

以下是有关该主题的更多信息:

  • 我已经检查了除log4j.xml之外的log4j.properties(没有)的类路径

这是log4j.xml文件:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>


    <!-- ============================== -->
    <!-- Append messages to the console -->
    <!-- ============================== -->


    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out" />

        <layout class="org.apache.log4j.PatternLayout">
            <!-- The default pattern: Date Priority [Category] Message\n -->
            <param name="ConversionPattern" value="[AC - %5p] [%d{ISO8601}] [%t] [%c{1} - %L] %m%n" />
        </layout>
    </appender>

    <appender name="logfile" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="./logs/server.log" />
        <param name="MaxFileSize" value="1000KB" />
        <param name="MaxBackupIndex" value="2" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="[AC - …
Run Code Online (Sandbox Code Playgroud)

java logging log4j

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