我在使用JUnit的Spring Boot 2.2.5.RELEASE项目上遇到了一个奇怪的问题。
我尝试详细解释我的问题:
1)我定义了一个服务。首先,我定义了一个名为OrderService的接口,如下所示:
package com.dgs.soc.service;
import java.util.List;
import com.dgs.soc.excelapi.dto.Order;
public interface OrderService {
public List<Order> getOrdersList();
}
Run Code Online (Sandbox Code Playgroud)
然后我定义了它的实现,目前名为OrderServiceImpl 的东西非常简单:
package com.dgs.soc.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;
import com.dgs.soc.excelapi.dto.Order;
import com.dgs.soc.repository.OrderRepository;
@Service
public class OrderServiceImpl {
public List<Order> getOrdersList() {
List<Order> result = new ArrayList<Order>();
return result;
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,此类由@Service注释进行注释。
问题是使用JUnit,我有这个测试类:
package com.dgs.soc.excelapi.integration;
// IMPORTS LIST
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { Application.class })
@WebAppConfiguration
@ActiveProfiles(profiles = { …Run Code Online (Sandbox Code Playgroud) 我对 Angular 和 Firebase\FireStore 很陌生,我发现在尝试将 Firestore 连接添加到我的项目时遇到了以下困难。
我正在按照官方文档将其添加到我的特定项目中:https : //github.com/angular/angularfire/blob/master/docs/install-and-setup.md
所以,首先,我通过 NPM 在我的项目中安装了 AngularFire:
npm install --save firebase @angular/fire
Run Code Online (Sandbox Code Playgroud)
然后我做了:
ng add @angular/fire
Run Code Online (Sandbox Code Playgroud)
然后我以这种方式配置了我的/src/environments/environment.ts文件:
export const environment = {
production: false,
firebase: {
apiKey: "MY-API-KEY",
authDomain: "soc-dashboard.firebaseapp.com",
databaseURL: "https://soc-dashboard.firebaseio.com",
projectId: "soc-dashboard",
storageBucket: "soc-dashboard.appspot.com",
messagingSenderId: "801320773797"
//appId: "1:801320773797:web:14e69306da7b0838d4c54c",
//measurementId: "G-BHVTXG6CY4"
}
};
Run Code Online (Sandbox Code Playgroud)
然后我以这种方式配置了我的/src/app/app.module.ts文件:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import { AppRoutingModule } from './app-routing.module';
import …Run Code Online (Sandbox Code Playgroud) firebase angular-module angularfire2 angular google-cloud-firestore
我有以下问题.
我有这个Microsoft SQL Server查询:
Select AVG(Severity) AS 'Average Severity' from VulnerabilityAlertDocument
Run Code Online (Sandbox Code Playgroud)
执行到Microsoft SQL Server Managment Studio,返回给我这个浮点数:7,34792844929602
现在我正在尝试创建一个简单实现此查询并返回获取值的C#方法,所以我做了类似这样的事情:
public double getVulnerabilitySeverityAverage()
{
double vulnerabilitySeverityAverage;
_strSQL = "Select AVG(Severity) AS 'Average Severity' from VulnerabilityAlertDocument";
System.Data.Common.DbCommand command;
command = _connection.CreateCommand();
command.CommandText = _strSQL;
vulnerabilitySeverityAverage = command.ExecuteNonQuery();
return vulnerabilitySeverityAverage;
}
Run Code Online (Sandbox Code Playgroud)
问题是,当执行前面的方法时,漏洞范围内的结果值不是预期值(7,34792844929602),但它是错误的值:-1.0
为什么?这有什么不对?我错过了什么?
TNX
我对 bash 脚本非常陌生,我需要创建一个简单的脚本,每 5 分钟将日期和时间插入日志文件并保存。
我能做些什么来做到这一点?我可以从什么开始呢?
我是JavaScript中的新手,我在比较2个字符串时遇到了问题.
进入一个函数我有这个代码:
var selectedProjectStatusText = selectedProjectStatus.options[selectedProjectStatus.selectedIndex].text;
alert("== " + selectedProjectStatusText == "-- Please Select --");
alert("=== " + selectedProjectStatusText === "-- Please Select --");
Run Code Online (Sandbox Code Playgroud)
我正在使用该alert()函数来尝试如何工作字符串比较器.
问题是alert()当selectedProjectStatusText变量包含-- Please Select --字符串时,我都说FALSE .
为什么?我错过了什么?可能是问题的原因是什么?我该如何解决?我错过了什么?
我对这个 JQuery 脚本有一些问题(在使用Jquery-1.9.1.min.js 的项目上):
$(document).ready(function () {
$("thead.opening").click(function () {
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
alert("INTO second function, chrome: " + is_chrome);
$(this).next().css('width', '10000000em');
$(this).next().css('display', 'table-row-group');
//$(this).next().css('display', is_chrome ? 'table-row-group' : 'table-row-group');
//alert($(this).next().css('display'));
});
});
Run Code Online (Sandbox Code Playgroud)
该脚本只是将 CSS 样式设置为与单击的thead元素相关的tbody元素,并按以下方式执行:
$(this).next().css('display', 'table-row-group');
Run Code Online (Sandbox Code Playgroud)
它可以工作,但我还必须为此 CSS 属性设置!important,但如果我这样做,它就无法工作:
$(this).next().css('display', 'table-row-group !important');
Run Code Online (Sandbox Code Playgroud)
所以在网上搜索我在 StackOverflow 上找到了这篇文章:How to apply !important using .css()?
因此,在前面的脚本中,我尝试使用:
$(this).next().style('width', '10000000em', 'important');
$(this).next().style('display', 'table-row-group', 'important');
Run Code Online (Sandbox Code Playgroud)
反而:
$(this).next().css('width', '10000000em');
$(this).next().css('display', 'table-row-group');
Run Code Online (Sandbox Code Playgroud)
但问题是我得到了这个错误的结果:
<tbody class="expanded" style="display: block; …Run Code Online (Sandbox Code Playgroud) 我知道在Java中我可以从String对象中提取子字符串,例如:
String string= "Hello World";
String subString = string.substring(5);
Run Code Online (Sandbox Code Playgroud)
在这个wat中,subString变量将只包含Hello字符串
而且我知道我也可以指定2个索引来选择子字符串,例如:
String subString = string.substring(6, 11);
Run Code Online (Sandbox Code Playgroud)
这将选择世界字符串.
但是,如果给定一个字符串,我想要选择原始字符串表示的子字符串,除了两个初始字符,我该怎么办.
所以我举例说:
String value = "12345"
Run Code Online (Sandbox Code Playgroud)
我的子串必须是345
我该怎么做?
我在 JQuery 中很新,我有以下问题。
我创建了这个 JQuery 函数,当用户选择一个文件到一个具有id=rendicontoAllegato的输入标签时,它会将这个文件的名称放入一个id=nomeDocumentoRendicontazione的隐藏 div到我的页面中
$(document).ready(function() {
$("#rendicontoAllegato").change(function() {
alert("DOCUMENTO dopo selezione: " + $("#nomeDocumentoRendicontazione").text());
var selectedFileName = $("#rendicontoAllegato").val();
$('#nomeDocumentoRendicontazione').append(selectedFileName);
});
});
Run Code Online (Sandbox Code Playgroud)
它工作正常,但唯一的问题是,如果我首先选择某个文件作为file1.txt,然后将另一个文件作为file2.txt选择到具有id=nomeDocumentoRendicontazione的 div 中,我将连接两个文件名。
所以我会有类似file1.txtfile2.txt 的东西,这对我不利。
如何替换具有id=nomeDocumentoRendicontazione的 div 的值以在其中附加一个新值?
在Java应用程序中,我有一个包含以下情况的单元测试:
BigDecimal rendimentoLordoProvvisiorioExpected = new BigDecimal(2.85000);
BigDecimal rendimentoLordoProvvisiorioDB = null;
rendimentoLordoProvvisiorioDB = pucManager.getRendimentoLordoProvvisorio(date);
assertTrue(rendimentoLordoProvvisiorioExpected.compareTo(rendimentoLordoProvvisiorioDB) == 0);
Run Code Online (Sandbox Code Playgroud)
所述的值rendimentoLordoProvvisiorioExpected变量被手动设置好的到2.85000和所获得的值rendimentoLordoProvvisiorioDB是2.85000.
问题是,当我这样做时,比较assertTrue() JUnit函数
assertTrue(rendimentoLordoProvvisiorioExpected.compareTo(rendimentoLordoProvvisiorioDB) == 0);
Run Code Online (Sandbox Code Playgroud)
它失败是因为rendimentoLordoProvvisiorioExpected似乎是2.850000000000000088817841970012523233890533447265625而不是2.85000(已设置).
为什么?如何修改以前的代码以将rendimentoLordoProvvisiorioExpected设置为预期值2.85000?
.NET C#应用程序存在以下问题。
我有这个字符串数组:
string[] uorsList = uors.Split(';');
Run Code Online (Sandbox Code Playgroud)
有时,此数组包含对应于空字符串(“”)的元素。
从此uorsList数组中删除所有为空字符串的元素的聪明方法是什么?
java ×3
javascript ×3
.net ×2
c# ×2
html ×2
jquery ×2
angular ×1
angularfire2 ×1
asp.net ×1
bash ×1
bigdecimal ×1
css ×1
dom ×1
firebase ×1
sh ×1
shell ×1
spring ×1
spring-boot ×1
sql-server ×1
string ×1
substring ×1