小编Tun*_*ung的帖子

如何为Spring Boot应用程序配置端口

如何配置Spring Boot应用程序侦听的TCP/IP端口,因此它不使用默认端口8080.

java port spring spring-boot server

728
推荐指数
37
解决办法
68万
查看次数

如何在Emacs中选择或突出显示某个块?

我想在没有鼠标的情况下选择或突出显示emacs中的块,而是像vim的可视模式一样在键盘上突出显示.从键盘上最简单的方法是什么?

emacs highlight selection

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

在urllib3中我应该使用什么来打开url而不是urlopen

我想写一段代码,如下所示:

from bs4 import BeautifulSoup
import urllib2

url = 'http://www.thefamouspeople.com/singers.php'
html = urllib2.urlopen(url)
soup = BeautifulSoup(html)
Run Code Online (Sandbox Code Playgroud)

但我发现我现在必须安装urllib3包.

此外,我找不到任何教程或示例来了解如何重写上面的代码,例如,urllib3没有urlopen.

请问任何解释或示例?!

P/S:我正在使用python 3.4.

python beautifulsoup web-scraping urllib3

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

groovy:如何访问属性文件?

我有一个Groovy应用程序,我想以编程方式访问message.properties中定义的属性.

作为测试我尝试了以下内容:

println "capacity.created: ${messages.properties['capacity.created']}"
Run Code Online (Sandbox Code Playgroud)

但它不起作用(抛出异常).

欢迎任何帮助

路易斯

multilingual grails groovy properties internationalization

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

Grails @Transactional与Spring @Transactional注释之间的差异

那么Grails Declarative Transactions就有一点了.它说:

grails.transaction.Transactional注释最初是在Grails 2.3中引入的.在2.3之前,使用了Spring的@Transactional注释.

但我似乎无法找出这两个注释之间的主要区别是什么.为什么未来的版本中没有使用Spring的注释?

grails annotations transactional grails-2.3 grails-2.5

16
推荐指数
3
解决办法
6604
查看次数

Grails Spring Security插件:获取302 for Ajax Request for timedout Session

我们使用带有Grails 2.2.1的Spring Security插件版本1.2.7.3.在我的Config.groovy手中:

grails.plugins.springsecurity.auth.ajaxLoginFormUrl = "/mylogin/authAjax"
Run Code Online (Sandbox Code Playgroud)

认为,当存在Ajax请求时,如果用户的HttpSession超时,Spring Security将调用authAjax()()MyloginController.

根据doc,我确保X-Requested-With带有值的头部XMLHttpRequest位于Ajax请求中,因此插件知道它是一个Ajax请求.

我的期望是authAjax()将被调用,我可以返回401,所以UI知道它需要弹出另一个登录屏幕.

但是,相反,在authAjax()调用get中,将302返回到UI,并将location字段设置为http://localhost:8080/MyApplication/mycontroller/authAjax

这意味着我必须在我的UI上输入非常hackey的东西.检查302并检查位置字段,然后让用户重新登录.我更愿意回归401.

我有什么想法我做错了吗?

太感谢了

grails spring-security grails-plugin

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

在grails 3中使用logback

Grails 3使用logback作为日志记录系统.

我需要一个如何在这种形式的grails 3中使用logback的示例

log.info("some Info")
Run Code Online (Sandbox Code Playgroud)

grails logging logback

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

在Windows操作系统中使用基于Unix的命令与Anaconda

我曾经在Windows 7中使用几个基于Unix的命令与Anaconda 2(即Python 2.7).例如,这些命令ls, mkdir, rm,...可以与Anaconda命令提示符一起正常工作.

最近,我升级到Windows 10并安装了使用Python 3.5运行的Anaconda 3.上面提到的这些命令不能在Anaconda 3中使用.我曾尝试卸载并重新安装Anaconda 3,但它可以像以前一样工作.

有人有建议吗?

python anaconda

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

Mock Grails Spring Security登录用户

寻找在某些单元/集成测试中模拟弹簧安全性的方法.

  • Grails:V2.1.0
  • Spring Security Core:V1.2.7.3

控制器具有以下内容:

// some action
def index(){
   def user = getLoggedInUser()
   render ....
}
...

private getLoggedInUser(){
    return User.get(springSecurityService.principal.id)
}
Run Code Online (Sandbox Code Playgroud)

我尝试了以下和其他各种方法,但无法让它工作:

void testSomething(){
    def dc = new SomeController()
    dc.springSecurityService = [
            encodePassword: 'password',
            reauthenticate: { String u -> true},
            loggedIn: true,
            principal: [username:"Bob"]]
    dc.index() 
    ... assertion....
Run Code Online (Sandbox Code Playgroud)

似乎用户没有被创建并且无法获得principle.id.任何建议或更好的选择?

testing grails mocking spring-security

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

如何更新外部配置文件而无需在Grails中重建war文件

如何在不重建Grails中的war文件的情况下更新外部配置文件(例如:config-ex.groovy,config-ex.properties),重新启动重启服务器和应用程序将从外部配置文件应用新更新

grails configuration-files application-settings

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