我正在尝试这个tutoial.我创建了新项目并运行它.TomCat开始了,但后来什么也没发生.我可以在浏览器中手动打开http://localhost:8080并查看TomCat主页.这意味着可以启动服务器.但是我无法打开index.jsp.这是启动后的屏幕:
截图
正如您所看到的,项目正在运行,但没有关于传递的环境变量的信息.没有日志.
我使用TomCat 7.0.27
想法12.1.6
在Opensuse 12.2上
我的tomcat HOME文件夹是 /usr/share/tomcat
有一个问题:Idea无法将/ usr/share/tomcat/conf中的conf文件复制到/home/loco/.IntelliJIdea12/system/tomcat//conf.我执行chmod 777 *了/usr/share/tomcat and the problem gone.
我也改变了TomCat的启动方式.这是默认值
/usr/share/tomcat/bin/catalina.sh run
Run Code Online (Sandbox Code Playgroud)
我换了
/usr/share/tomcat/bin/catalina.sh start
Run Code Online (Sandbox Code Playgroud)
所有其他步骤均按照教程完成.
我是Spring MVC的新手,但是我在文档中什么都没有找到。假设我有一个控制器/ accounts,它接受POST请求来创建一个帐户。具有相同帐户ID的两个请求(几乎)同时出现。ASFAIK dispatcherServlet管理请求。
在第一个请求完成之前,是否将第二个请求放入队列?还是会有两个线程同时处理两个请求?
更新:
检查官方Spring教程:构建REST服务。有方法的控制器add:
@RequestMapping(method = RequestMethod.POST)
ResponseEntity<?> add(@PathVariable String userId, @RequestBody Bookmark input) {
this.validateUser(userId);
return this.accountRepository
.findByUsername(userId)
.map(account -> {
Bookmark result = bookmarkRepository.save(new Bookmark(account,
input.uri, input.description));
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(ServletUriComponentsBuilder
.fromCurrentRequest().path("/{id}")
.buildAndExpand(result.getId()).toUri());
return new ResponseEntity<>(null, httpHeaders, HttpStatus.CREATED);
}).get();
}
Run Code Online (Sandbox Code Playgroud)
控制器只是bean,默认情况下它们是单例。当接收到两个同时请求时,两个线程将使用控制器的同一实例。假设第一个线程已经保存了新书签并正在执行
httpHeaders.setLocation(ServletUriComponentsBuilder
.fromCurrentRequest().path("/{id}")
.buildAndExpand(result.getId()).toUri());
Run Code Online (Sandbox Code Playgroud)
同时第二个线程刚刚执行
Bookmark result = bookmarkRepository.save(new Bookmark(account,
input.uri, input.description));
Run Code Online (Sandbox Code Playgroud)
在这种情况下,将返回result.getId()).toUri()由第二个线程创建的第一个线程。
它是正确的工作流程,并且该控制器是线程安全的吗?
如何FlushMode.ALWAYS在Spring Boot应用程序中设置所有会话?有这个设置会很好application.yml.
UPDATE
我在application.yml中尝试了两种方法:
spring.jpa.properties.org.hibernate.flushMode: ALWAYS
spring.jpa.org.hibernate.flushMode: ALWAYS
Run Code Online (Sandbox Code Playgroud)
然而下一个代码:
Session ses = factory.openSession();
ses.setFlushMode(FlushMode.ALWAYS);
LOG.debug("!!!Session.FlushMode = " + ses.getFlushMode());
LOG.debug("!!!NewSession.FlushMode = " + factory.openSession().getFlushMode());
Run Code Online (Sandbox Code Playgroud)
得到:
DEBUG 47225 --- : !!!Session.FlushMode = ALWAYS
DEBUG 47225 --- : !!!NewSession.FlushMode = AUTO
Run Code Online (Sandbox Code Playgroud) 为了实现HMAC身份验证,我制作了自己的过滤器,提供程序和令牌。RestSecurityFilter:
public class RestSecurityFilter extends AbstractAuthenticationProcessingFilter {
private final Logger LOG = LoggerFactory.getLogger(RestSecurityFilter.class);
private AuthenticationManager authenticationManager;
public RestSecurityFilter(String defaultFilterProcessesUrl) {
super(defaultFilterProcessesUrl);
}
public RestSecurityFilter(RequestMatcher requiresAuthenticationRequestMatcher) {
super(requiresAuthenticationRequestMatcher);
}
@Override
public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse response) throws AuthenticationException, IOException, ServletException {
AuthenticationRequestWrapper request = new AuthenticationRequestWrapper(req);
// Get authorization headers
String signature = request.getHeader("Signature");
String principal = request.getHeader("API-Key");
String timestamp = request.getHeader("timestamp");
if ((signature == null) || (principal == null) || (timestamp == null))
unsuccessfulAuthentication(request, response, new BadHMACAuthRequestException("Authentication attempt failed! Request …Run Code Online (Sandbox Code Playgroud) 我在application.properties中有简单的日志设置:
logging.file = logs/debug.log
logging.level.org.hibernate.SQL = DEBUG
logging.level.org.hibernate.type = TRACE
Run Code Online (Sandbox Code Playgroud)
我有一个包裹co.myapp.notifier.我希望这个包的所有类都能登录logs/notifier.log.我试过
/sf/answers/675656761/
和
/sf/answers/50984601/但
没有运气.在所有情况下,消息都会发送到我的debug.log
在我的 Spring Boot 项目中,我想使用 Flyway-maven-plugin。我的pom:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.1</version>
<configuration>
<url>jdbc:mysql://localhost:3306/my_database?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&connectionCollation=utf8_unicode_ci&characterSetResults=UTF-8</url>
<user>root</user>
<password>${spring.datasource.password}</password>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是我的 application.yml
spring:
profiles.active: default
---
spring:
profiles: default
spring.datasource:
password: root
Run Code Online (Sandbox Code Playgroud)
据我了解,使用mvn flyway:info我需要一些插件来读取我的 application.yml 。或者也许还有另一种方法?
我有application.yml,代码如下:
logging:
file: logs/keyserver.log
level:
org.springframework.web: 'DEBUG'
Run Code Online (Sandbox Code Playgroud)
它工作正常,除了这种情况:
public class TransactionBuilder extends Wallet {
private final Logger LOG = LoggerFactory.getLogger(TransactionBuilder.class);
@Override
public RedeemData findRedeemDataFromScriptHash(byte[] payToScriptHash) {
LOG.debug("payToScriptHash = " + HEX.encode(payToScriptHash));
}
}
Run Code Online (Sandbox Code Playgroud)
消息既不出现在日志文件中也不出现在屏幕上.
然而
LOG.info("payToScriptHash = " + HEX.encode(payToScriptHash));
LOG.error("payToScriptHash = " + HEX.encode(payToScriptHash));
Run Code Online (Sandbox Code Playgroud)
工作得很好.
我是春天的新手.目标是学习Spring,将Spring用作生产应用程序,因为它是行业标准.
应用程序的要求:Hibernate,Security,MVC,RESTful,DI等.将来可能会添加其他Spring框架.我正在读"Spring in Action.第三版." 克雷格沃尔斯.他给出了如何使用注释的示例,但无论如何都使用了.xml.我想知道我是否可以只使用java类编写应用程序来配置应用程序中的所有模块.我发现Spring Boot能够开发不使用xml文件.但是我读了http://steveperkins.com/use-spring-boot-next-project/这篇文章并且作者说Boot还没有准备好用于生产应用程序.据我所知,Boot隐藏了所有配置工作.另外我担心的是,将来知道Spring的java开发人员将无法处理Spring Boot,我也找不到适合该项目的工程师.基于此,我有以下问题: