所以我很惊讶这个问题的答案并不容易找到,但是我希望在数据库生成后插入一些数据.
RootConfig.java:
...
@Bean
public DataSource dataSource() throws SQLException {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
return builder.setType(EmbeddedDatabaseType.HSQL)
.setName("db")
.addScript("setup_data.sql")
.continueOnError(true)
.build();
}
@Bean
public EntityManagerFactory entityManagerFactory() throws SQLException {
EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter();
vendorAdapter.setGenerateDdl(true);
vendorAdapter.setShowSql(true);
vendorAdapter.setDatabase(Database.HSQL);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
Map<String, Object> props = new HashMap<>();
props.put("eclipselink.weaving", "false");
props.put("eclipselink.target-database", HSQLPlatform.class.getName());
props.put("eclipselink.cache.shared.default", "false");
props.put("eclipselink.logging.parameters", "true");
props.put("eclipselink.logging.level", "FINEST");
props.put("eclipselink.logging.level.sql", "FINEST");
props.put("eclipselink.logging.level.cache", "FINEST");
factory.setJpaPropertyMap(props);
factory.setPackagesToScan("com.citysports.leaguesports.domain");
factory.setDataSource(dataSource());
factory.afterPropertiesSet();
return factory.getObject();
}
...
Run Code Online (Sandbox Code Playgroud)
我正在生成ddl,但是当我addScript('setup_data.sql')收到错误时,因为它还没有生成表.如何在ddl生成后运行脚本?
所以我有一个指令,里面有一个复选框.我需要在复选框的值更改时进行Web服务调用.如何在单击时获取该复选框的值?我希望复选框仅限于指令的范围.
myModule.directive('test', function() {
return {
restrict: 'A',
replace: true,
scope:{},
template:
'<div>'+
'<input type="checkbox" ng-click="toggleRoomLock()" name="lockRoom" value="lock" ng-model="lockRoom">'+
'</div>',
link: function(scope, element, attrs) {
scope.toggleRoomLock = function(){
//GET VALUE OF CHECKBOX HERE
};
}
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用该值,scope.lockRoom但我未定义.有什么建议?
我有一个或多或少看起来像这样的 POJO:
public class Action {
private String eventId;
private List<ActionArgument> arguments;
//action to perform when this action is done
private List<Action> onCompleteActions;
public Action() {
}
public Action(String eventId, List<ActionArgument> arguments, List<Action> onCompleteActions) {
this.eventId = eventId;
this.arguments = arguments;
this.onCompleteActions = onCompleteActions;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId;
}
public List<ActionArgument> getArguments() {
return arguments;
}
public void setArguments(List<ActionArgument> arguments) {
this.arguments = arguments;
}
public List<Action> getOnCompleteActions() …Run Code Online (Sandbox Code Playgroud) 我有一个我正在构建的离子/ cordova应用程序.在浏览器中进行开发时我没有任何问题,但是当我在设备或模拟器上构建和运行时,他们无法找到我的图像.我已经确认图像被复制到平台项目中,但我是否必须做一些特殊的事情才能使用它们?对于android,他们正在被复制到assets/www/images我试图在我的CSS中使用类似的东西引用它们:
.myImage{
height: 20px;
width: 20px;
background: url('/images/my_image.png') no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
但是在控制台中我404 Not Found在ios和android上都出错了.我究竟做错了什么?
我浏览了各种帖子并尝试了几件事但我无法让事情正常进行.我不觉得应该那么难,但这就是我得到的.我只想将文件发布到我的服务器以进行测试.它应该像我从<input type="file"/>网页上的标准上传它一样工作.
这是我想要测试的实际处理程序:
[Route("MyAction")]
[HttpPost]
public IHttpActionResult MyAction()
{
try
{
var request = HttpContext.Current.Request;
if (request.Files.Count == 1)
{
var postedFile = request.Files[0];
if (request.Files[0].FileName.EndsWith(".zip"))
{
// unzip the file
// do stuff
}
}
}
catch
{
return new ValidationError("An error has occurred and has been logged");
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的测试:
public void SetupServer()
{
server = TestServer.Create(app =>
{
var startup = new Startup();
startup.ConfigureOAuth(app);
var config = new HttpConfiguration();
WebApiConfig.Register(config);
app.UseWebApi(config);
});
}
[Test]
public …Run Code Online (Sandbox Code Playgroud) 我认为必须有办法做到这一点,但我无法弄明白.我正在尝试为我的应用程序添加侧边栏视图,并认为如果我可以将侧边栏作为一个侧边栏,那将是非常光滑的ui-view.我遇到的问题是我不想为每个页面指定每个可能的侧边栏视图.我希望能够只在侧栏中设置视图并保持当前/主视图相同.
这个小提琴演示了我的问题.
所以我有一个看起来像这样的函数:
private int getNumber(String commandChunk)
{
Pattern pattern = Pattern.compile("R(\\d+)");
Matcher m = pattern.matcher(commandChunk);
return Integer.parseInt(m.group(1));
}
Run Code Online (Sandbox Code Playgroud)
用"R0"调用它.我希望它返回int:0,但我在return语句中得到一个非法的状态异常.我究竟做错了什么?我不明白为什么我不能说int myNum = getNumber("R0")最终myNum = 0.
所以我试图制作一个如下所示的高清图:

但我似乎无法让边界只包裹酒吧.这是我能得到的最接近的:

有谁知道我怎么做到这一点?以下是我的选择:
highcharts({
chart: {
backgroundColor: 'transparent',
plotBorderColor: '#9E9E9E',
plotBorderWidth: 2,
height: 200,
type: 'bar'
},
title: {
text: null
},
credits: {
enabled: false
},
yAxis: {
title: {
text: null
},
labels: {
enabled: false
},
tickLength: 0,
lineColor: 0,
lineWidth: 0,
gridLineWidth: 0
},
xAxis: {
title: {
text: null
},
labels: {
enabled: false
},
tickLength: 0,
lineColor: 0,
lineWidth: 0
},
plotOptions: {
bar: {
borderColor: '#000000'
}
},
legend: {
// reversed: true, …Run Code Online (Sandbox Code Playgroud) 我有一个api调用,作为另一个api调用的简单passthrough(出于安全目的).我只是想返回json响应,所以我不必复制一个对象或为一个调用创建一个完整的ws客户端这可能吗?这是我得到的:
[Route("PreUpload")]
[HttpPost]
[Authorize]
public async Task<IHttpActionResult> PreUpload(PreUploadInfoModel model)
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(ConfigurationManager.AppSettings["FileServerURI"].ToString());
model.UserId = CurrentUserID;
var response = await client.PostAsJsonAsync("api/files/PreUpload", model);
if (response.IsSuccessStatusCode)
{
// response.Content.ReadAsStringAsync().Result = "{\"UploadId\":\"blah\",\"NextChunk\":0,\"ChunkSize\":123,\"Key\":\"someKey\",\"Token\":\"myToken\"}"
return Json(response.Content.ReadAsStringAsync().Result);
}
return BadRequest(response.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
应该简单吧?但这会将此返回给浏览器:
undefined:2.1241246524224146e+43
我不太了解C#,但我有这个项目,我正在努力做我想做的事情:
SortedDictionary<int, List<ChessMove>> possibleMovesByRank = new SortedDictionary<int, List<ChessMove>>();
...
var best = possibleMovesByRank.Keys.Last();
Run Code Online (Sandbox Code Playgroud)
从我能够找到的,这应该使用linq返回具有最高值的键,但VS给我一个错误:
SortedDictionary.KeyCollection does not contain a definition for 'Last' and no extension method for 'Last'
Run Code Online (Sandbox Code Playgroud)
我错过了什么或者我的项目设置不正确还是什么?