我在mongodb上相当新,而我正在尝试进行有序的mongodb查询.但是不推荐使用spring数据mongodb的sort方法.所以我用了org.springframework.data.domain.Sort
Query query = new Query();
query.with(new Sort(Sort.Direction.ASC,"pdate"));
return mongoTemplate.find(query, Product.class);
Run Code Online (Sandbox Code Playgroud)
我用过这个代码块.但它没有对数据进行排序.那么您是否可以选择使用任何有用的方法进行此练习?
我已经实现了基于令牌的身份验证(没有spring安全性).因此,在GenericFilterBean中,它会检查并声明令牌.
public class MyTokenFilter extends GenericFilterBean {
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws MyAuthException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
if (!"OPTIONS".equals(request.getMethod())) {
String authHeader = request.getHeader("Authorization");
if (authHeader == null || !authHeader.startsWith("Token ")) {
throw new MyAuthException("Authorization header needed"); // Should return custom http status response like 400
}
String token = authHeader.substring(6);
try {
claimToken(token);
} catch (Exception e) {
throw new MyAuthException("Invalid token."); // Should return custom http …Run Code Online (Sandbox Code Playgroud) 我在docker中有一个springboot应用程序容器和mongodb容器.
docker run -p 27017:27017 -d --name myMongo mongo
Run Code Online (Sandbox Code Playgroud)
所以我首先运行mongodb容器,然后运行springboot容器.
docker run -p 8080:8080 --name mySpringApp --link myMongo:mongodb mySpringApp
Run Code Online (Sandbox Code Playgroud)
之后我想在springboot app中获取环境变量.
MONGODB_PORT=tcp://172.17.0.5:27017
MONGODB_PORT_5432_TCP=tcp://172.17.0.5:27017
MONGODB_PORT_5432_TCP_PROTO=tcp
MONGODB_PORT_5432_TCP_PORT=27017
MONGODB_PORT_5432_TCP_ADDR=172.17.0.5
Run Code Online (Sandbox Code Playgroud)
在application.properties文件中,我通常喜欢ip和port的常量配置,所以它连接mongodb容器没有任何问题.
spring.data.mongodb.host=172.17.0.56
spring.data.mongodb.port=27017
Run Code Online (Sandbox Code Playgroud)
但是在那个application.properties文件中我有办法获得那个环境变量,顺便说一句,我尝试过 #{systemEnvironment['MONGODB_PORT_5432_TCP_ADDR']}这种表示法.但我的应用程序无法连接到mongodb容器.有没有办法对这种情况有任何好的做法,我也尝试AbstractMongoConfiguration使用@Value注释实现get systemEnvironment变量.
我正在尝试制作一个小的披萨订单,但我的计算有问题.选择披萨后,单价和总计算都可以,但选择添加会引入问题.更改NumericUpDown值后,卡路里不正确(所有单位都有不变的价格和卡路里).NumericUpDown的名称是numberofunit.我该怎么计算它们?
if (pepper.Checked)
{
string peppereklendi =
Convert.ToString(Convert.ToDouble(unitprice.Text)+ pepperprice);
unitprice.Text = peppereklendi;
total.Text =
Convert.ToString(Convert.ToDecimal(unitprice.Text) * numberofunit.Value);
string pepperkaloriekle =
Convert.ToString(Convert.ToInt16(gizlikalori.Text) + pepperkalori);
gizlikalori.Text = pepperkaloriekle;
amountofcalorie.Text =
Convert.ToString(Convert.ToDecimal(gizlikalori.Text) * numberofunit.Value);
}
else
{
string peppereklendi = unitprice.Text;
unitprice.Text =
Convert.ToString(Convert.ToDouble(peppereklendi) - pepperprice);
total.Text = Convert.ToString(Convert.ToDecimal(unitprice.Text) * numberofunit.Value);
string pepperkaloriekle = gizlikalori.Text;
gizlikalori.Text =
Convert.ToString(Convert.ToDouble(pepperkaloriekle) - pepperkalori);
amountofcalorie.Text =
Convert.ToString(Convert.ToDecimal(gizlikalori.Text) * numberofunit.Value);
}
Run Code Online (Sandbox Code Playgroud)
此代码是胡椒的复选框代码.
我有一套redis。该集合最多可存储20个成员(通过SADD命令添加)。我的问题是;我需要在需要时更新该成员。每个会员最多需要修改 10 次。设置成员是 json 作为字符串。我脑子里只有解决方案,也没有让所有成员更新并再次重新创建该集。但这似乎很愚蠢。
我知道有一个ZADD带有分数支持的排序集,它似乎也合适,我也需要更新像 json 中的数据这样的分数,但我只是想知道是否有任何方法以有效的方式更新成员,或者在 redis 方式上更新成员不可接受?
注意:Redis 数据存储由 Node.js 和 Java 客户端使用。
这是代码,但它不适用于IE8和7(IE9,chrome,firefox,safari,opera都可以).我尝试了很多东西(meta utf-8代码,php头代码,接收警报,缓存:false).我能做什么,我需要帮助.谢谢你的兴趣.
var request = $.ajax({
type:"GET",
url: "_veri.php?t=icerik_getir&id="+tabopen,
dataType: "html",
});
request.done(function(msg) {
$(".tab-contentmenu").html(msg);
});
Run Code Online (Sandbox Code Playgroud)
编辑:
alert为我提供了所有浏览器中请求的数据,但仍然没有".tab-contentmenu"中的请求数据,我该怎么办?
var request = $.ajax({
type:"GET",
context: document.body,
url: "_veri.php?t=icerik_getir&id="+tabopen,
dataType: "html"
});
request.done(function(msg) {
$(".tab-contentmenu").html(msg);
alert(msg);
});
Run Code Online (Sandbox Code Playgroud) ajax jquery getmethod internet-explorer-8 internet-explorer-7
我想在我的Windows窗体应用程序中使用谷歌文本语音,它会读取标签.我添加了System.Speech参考.如何通过按钮点击事件读取标签? http://translate.google.com/translate_tts?q=testing+google+speech这是谷歌文本到语音API,或者我如何使用微软的本机文本语音?
我的项目有问题.它在部署项目时提供异常.我正在使用Tomcat7和JRE1.7.对于maven依赖到web-inf/lib配置的部署程序集,一切都很好.
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoSuchMethodError: org.springframework.core.type.classreading.CachingMetadataReaderFactory.clearCache()V
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:325)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
这是pom.xml:
<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>com</groupId>
<artifactId>ecommerce</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>ecommerce Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>3.2.3.RELEASE</spring.version>
<springsecurity.version>3.1.4.RELEASE</springsecurity.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency> …Run Code Online (Sandbox Code Playgroud)