Facebook基于JavaScript.为什么它不依赖于jQuery(或任何其他类似的库)?
编辑:为何关闭此问题?这不是主观的.facebook不使用jQuery(或任何其他框架)是有原因的,我要求的.
如何获取连接到我的应用程序(C#NET控制台应用程序)运行的计算机的所有IP地址?我需要将WCF服务绑定到主IP地址,并返回完整IP地址列表的列表.
using System.Net;
string myHostName = Dns.GetHostName().ToString();
string ipAddress = Dns.Resolve(HostName).AddressList[0].ToString();
Run Code Online (Sandbox Code Playgroud)
这就是我现在正在使用的获取主IP地址,但我无法弄清楚如何让其余的返回它们.
如果我将WCF服务绑定到localhost:8000,是否会在主服务器上公开它?
我有一个使用Spring Framework和Git的Java项目,我想显示一个内部版本号.我找到了Build Number Maven插件.使用Git,内部版本号是一个Git哈希.我不喜欢这个,我认为约会更有表现力.
我发现这篇优秀的博客文章解释了如何使用不同的SVN和Git配置文件编号插件.由于我只使用Git,而不是创建新的配置文件,我只是在我的构建标记中复制了插件部分.
当我运行"mvn package"时,它告诉我:
[INFO] --- buildnumber-maven-plugin:1.0:create (default) @ sherd ---
[INFO] Storing buildNumber: 2011-08-04_21-48_stivlo at timestamp: 1312487296631
Run Code Online (Sandbox Code Playgroud)
哪个看起来不错,但我想知道,它存放在哪里?"git status"没有检测到任何新文件,它似乎不在目标/中(目标/在我的.gitignore中).
也许我要更改配置以将内部版本号存储在文件中?如何使用内部版本号值?
感谢Michael-O的提示,我在Maven入门指南中阅读了有关如何过滤资源文件的章节.我在src/main/resources/properties/application.properties中创建了一个文件application.properties,其中包含以下内容:
# application properties
application.name=${pom.name}
application.version=${pom.version}
application.build=${buildNumber}
Run Code Online (Sandbox Code Playgroud)
我在构建部分中添加了以下XML代码段:
<resources>
<resource>
<directory>src/main/resources/properties</directory>
<filtering>true</filtering>
</resource>
</resources>
Run Code Online (Sandbox Code Playgroud)
现在,当我从命令行"mvn package"调用时,此属性文件将保存在target/classes/properties/application.properties中,例如具有以下内容:
# application properties
application.name=Sherd Control Panel
application.version=1.0.1-SNAPSHOT
application.build=2011-08-05_05-55_stivlo
Run Code Online (Sandbox Code Playgroud)
从命令行一切正常,但是,叹息,m2eclipse给出了Build错误:
05/08/11 6.05.03 CEST: Build errors for obliquid-cp;
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
org.codehaus.mojo:buildnumber-maven-plugin:1.0:create (default) on project
sherd: Cannot get the branch information from …Run Code Online (Sandbox Code Playgroud) 据我了解,无论是DataSource和JdbcTemplates是threadsafe,那么您可以配置的一个实例JdbcTemplate,然后安全地注入该共享引用到多个DAO(或仓库).也DataSource应该是Spring单例,因为它管理连接池.
官方的Spring文档JdbcTemplate最佳实践解释了替代方案(手册的摘录用斜体,方括号之间的注释:
new JdbcTemplate(dataSource)]但是,稍后的说明会阻止刚刚提出的所有选项:
配置完成后,JdbcTemplate实例就是线程安全的.如果您的应用程序访问多个数据库(可能需要多个DataSource,以及随后多个不同配置的JdbcTemplates),您可能需要多个JdbcTemplate实例.
换句话说,刚才提出的所有选项都会导致有多个JdbcTemplate实例(每个DAO一个),并且在文档说明在使用单个数据库时不需要这样做.
我要做的是直接注入JdbcTemplate需要它的各种DAO,所以我的问题是,这样做是否可以?而且,您是否也认为Spring参考文档是自相矛盾的?还是我的误会?
我在设置datanucleus增强器时遇到问题,需要与谷歌应用程序引擎项目一起使用.如果我使用datanucleus eclipse插件一切顺利,但在我的maven项目中,我得到一个奇怪的冲突版本错误.
我的POM有这些数据核参考:
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>1.1.0</version>
</dependency>
...
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<mappingIncludes>**/*.class</mappingIncludes>
<verbose>true</verbose>
<enhancerName>ASM</enhancerName>
<api>JDO</api>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我尝试构建项目时,我收到以下错误:
Exception in thread "main" Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.0/**datanucleus-core-1.1.0.jar**" is already registered, and you are trying to register an identical plugin located at URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.3/**datanucleus-core-1.1.3.jar**." org.datanucleus.exceptions.NucleusException: Plugin (Bundle) "org.datanucleus" is already registered. Ensure …
我正在尝试使用Java和Scalr 3.2创建此图像的高质量缩略图

这是相关的源代码,其中THUMB_WIDTH = 77和THUMB_HEIGHT = 57
BufferedImage srcImg = ImageIO.read(new File(sourceFile));
BufferedImage dstImg = Scalr.resize(srcImg, Scalr.Method.QUALITY,
THUMB_WIDTH, THUMB_HEIGHT);
ImageIO.write(dstImg, format, new File(destFile));
Run Code Online (Sandbox Code Playgroud)
如果我使用format = "png",结果如下:

如果我使用format = "jpg",结果如下:

通过imagemagick识别,我发现JPEG的质量保存为75,完全不足以创建美观的缩略图.PNG对我来说也不好看.
以下是原始文件的标识输出和两个缩略图:
$ identify 42486_1.jpg 42486_s1.jpg 42486_s1.png
42486_1.jpg JPEG 580x435 580x435+0+0 8-bit DirectClass 50.6KB 0.000u 0:00.000
42486_s1.jpg[1] JPEG 77x58 77x58+0+0 8-bit DirectClass 2.22KB 0.000u 0:00.000
42486_s1.png[2] PNG 77x58 77x58+0+0 8-bit DirectClass 12.2KB 0.000u 0:00.000
Run Code Online (Sandbox Code Playgroud)
我想从Controller中找到Spring中webapp的绝对URL.我知道JSTL c:url,但我需要来自Controller内部的这些信息.
@Controller
public class AuthorizeController {
@Autowired
private Authorizer auth;
@RequestMapping("/auth")
public String sendToAuthorization() {
String baseUrl = "http://localhost:8080/tasks/";
return "redirect:" + auth.getAuthorizationUrl(baseUrl);
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,baseUrl是硬编码的,我可以通过Spring配置将它提供给Authorizer类,但我确信可以在Controller中从Spring获取此信息.我试图google"spring mvc url"并找不到解决这个问题的方法.
我在控制器中,我想重定向回URL,比如/ home/news/example#comment1423
如何将哈希值添加到返回参数中?
return $this->redirect(
$this->generateUrl("news_view", array("permalink" => "example"))
);
Run Code Online (Sandbox Code Playgroud) 如果http://foo.com重定向到重定向到的1.2.3.4重定向http://finalurl.com,我如何使用Ruby找到登陆URL"http://finalurl.com"?
我正在尝试使用Groovy的XmlSlurper解析和修改Maven的pom.xml.我的pom.xml声明了名称空间xsi.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a-group-id</groupId>
<artifactId>an-artifact-id</artifactId>
Run Code Online (Sandbox Code Playgroud)
我的Groovy源代码如下:
import groovy.xml.XmlUtil
def pom = new XmlSlurper().parse('pom.xml')
.declareNamespace('': 'http://maven.apache.org/POM/4.0.0',
xsi: 'http://www.w3.org/2001/XMLSchema-instance')
//manipulate the pom
println XmlUtil.serialize(pom)
Run Code Online (Sandbox Code Playgroud)
正如您所注意到的,我已将第一个命名空间声明为空.但是在输出中,tag0随处可见.
<?xml version="1.0" encoding="UTF-8"?>
<tag0:project xmlns:tag0="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<tag0:modelVersion>4.0.0</tag0:modelVersion>
<tag0:groupId>a-group-id</tag0:groupId>
<tag0:artifactId>an-artifact-id</tag0:artifactId>
Run Code Online (Sandbox Code Playgroud)
怎么避免呢?
目前我的解决方法是手动删除标签:
println XmlUtil.serialize(pom).replaceAll('tag0:', '').replaceAll(':tag0', '')
Run Code Online (Sandbox Code Playgroud) java ×3
networking ×2
.net ×1
build ×1
c# ×1
datanucleus ×1
facebook ×1
frameworks ×1
groovy ×1
ip ×1
java-2d ×1
javascript ×1
jdbctemplate ×1
jquery ×1
maven ×1
maven-2 ×1
maven-plugin ×1
parsing ×1
redirect ×1
routing ×1
ruby ×1
scalr ×1
servlets ×1
spring ×1
spring-mvc ×1
symfony ×1
url-routing ×1
wcf ×1
xml ×1
xmlslurper ×1