我想使用eval()执行以下操作.最好的方法是什么?
config: function(config) {
for (var key in config) {
if (config.hasOwnProperty(key)) {
console.log('setting: ' + key + ' = ' + config[key]);
eval(key + ' = "' + config[key] + '"');
}
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试配置我的Spring Boot应用程序以使用Apache Shiro作为其安全框架.我有一切使用PropertiesRealm,现在我正在尝试使用JdbcRealm和Spring Boot的内置H2数据库.这是我在pom.xml中的依赖项:
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的schema.sql:
create table if not exists users (
username varchar(256),
password varchar(256),
enabled boolean
);
create table if not exists user_roles (
username varchar(256),
role_name varchar(256)
);
Run Code Online (Sandbox Code Playgroud)
我的data.sql:
insert into users (username, password, enabled) values ('user', '04f8996da763b7a969b1028ee3007569eaf3a635486ddab211d512c85b9df8fb', true);
insert into user_roles (username, role_name) values ('user', …Run Code Online (Sandbox Code Playgroud) setupJest.js在运行 React Native 测试之前,我使用了以下文件。
// Required to correctly polyfill React-Native
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
global.XMLHttpRequest = jest.fn();
global.fetch = jest.fn();
if (typeof window !== 'object') {
global.window = global;
global.window.navigator = {};
}
const EventEmitter = require('EventEmitter');
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
class NativeEventEmitter extends EventEmitter {
constructor() {
super(RCTDeviceEventEmitter.sharedSubscriber);
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个示例测试:
/**
* @format
*/
import 'react-native';
import React from 'react';
import App from '../App';
// Note: …Run Code Online (Sandbox Code Playgroud) 我创建了一个启用了 i18n 的 Spring Boot 2.1.3 应用程序,添加了 devtools,并安装了 Firefox LiveReload 扩展。不幸的是,当我更改 Thymeleaf 模板或 i18n 消息时,它并没有改变。在春季启动文件似乎表明,所有你需要做的就是安装devtools,它会禁用静态资源的缓存。
这是我为创建应用程序所做的工作:
mkdir bootiful-i18n
cd bootiful-i18n
http https://start.spring.io/starter.zip dependencies==web,thymeleaf -d | tar xvz
Run Code Online (Sandbox Code Playgroud)
然后我创建了一个HomeController.java:
package com.example.demo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
@GetMapping("/")
String home() {
return "home";
}
}
Run Code Online (Sandbox Code Playgroud)
我在以下位置创建了一个 Thymeleaf 模板src/main/resources/templates/home.html:
<html xmlns:th="http://www.thymeleaf.org">
<body>
<h1 th:text="#{title}"></h1>
<p th:text="#{message}"></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我添加了一个messages.properties文件src/main/resources:
title=Welcome
message=Hello! I hope you're having a great day.
Run Code Online (Sandbox Code Playgroud)
这一切都很好。为了启用热重载,我将 …
java ×2
spring-boot ×2
javascript ×1
jestjs ×1
react-native ×1
shiro ×1
spring ×1
thymeleaf ×1