我想在我的swift项目中创建一个函数,将String转换为Dictionary json格式,但是我遇到了一个错误:
无法转换表达式的类型(@lvalue NSData,选项:IntegerLitralConvertible ...
这是我的代码:
func convertStringToDictionary (text:String) -> Dictionary<String,String> {
var data :NSData = text.dataUsingEncoding(NSUTF8StringEncoding)!
var json :Dictionary = NSJSONSerialization.JSONObjectWithData(data, options:0, error: nil)
return json
}
Run Code Online (Sandbox Code Playgroud)
我在Objective-C中创建了这个函数:
- (NSDictionary*)convertStringToDictionary:(NSString*)string {
NSError* error;
//giving error as it takes dic, array,etc only. not custom object.
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
return json;
}
Run Code Online (Sandbox Code Playgroud) java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 and java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
当我运行 spring boot 应用程序时,我收到此异常 )
我正在使用以下工具
STS 3.9.10 发布
Open JDK 14 64 位
Spring boot 2.2.5
它在 oracle jdk 上运行良好,但在 openjdk 上运行失败。我没有使用任何常规库。这是基于 Maven 的 Spring Boot 项目。
我有一个带角度前端的mvc 5项目.我想按照本教程https://angular.io/guide/router中的说明添加路由.所以在我的_Layout.cshtml中我添加了一个
<base href="/">
Run Code Online (Sandbox Code Playgroud)
并在我的app.module中创建了我的路由.但是当我运行这个时,我收到以下错误:
Error: Template parse errors:
'router-outlet' is not a known element:
1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<a routerLink="/dashboard">dashboard</a>
</nav>
[ERROR ->]<router-outlet></router-outlet>
"): ng:///AppModule/AppComponent.html@5:0
Run Code Online (Sandbox Code Playgroud)
在我的app.component中
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
给出一个错误,告诉我Visual Studio无法解析标签'router-outlet'.有任何建议我如何解决这个错误?我错过了参考或导入或只是忽略了什么?
下面是我的package.json,app.component和app.module
的package.json
{
"version": "1.0.0",
"name": "app",
"private": true,
"scripts": {},
"dependencies": {
"@angular/common": "^4.2.2", …
Run Code Online (Sandbox Code Playgroud) 这是代码:
@Repository
public interface AccountRepository extends JpaRepository<Account, Long> {}
Run Code Online (Sandbox Code Playgroud)
来自Spring Data JPA项目的JpaRepository.
这是测试代码:
public class JpaAccountRepositoryTest extends JpaRepositoryTest {
@Inject
private AccountRepository accountRepository;
@Inject
private Account account;
@Test
@Transactional
public void createAccount() {
Account returnedAccount = accountRepository.save(account);
System.out.printf("account ID is %d and for returned account ID is %d\n", account.getId(), returnedAccount.getId());
}
}
Run Code Online (Sandbox Code Playgroud)
结果如下:
account ID is 0 and for returned account ID is 1
Run Code Online (Sandbox Code Playgroud)
这是来自CrudReporsitory.save()javadoc:
保存给定的实体.使用返回的实例进行进一步操作,因为save操作可能已完全更改了实体实例.
以下是Spring Data JPA中SimpleJpaRepository的实际代码:
@Transactional
public T save(T entity) {
if (entityInformation.isNew(entity)) { …
Run Code Online (Sandbox Code Playgroud) 我有一个名为GoogleWeather的类,我想将它转换为另一个类CustomWeather.
有没有任何设计模式可以帮助您转换类?
我正在尝试使用以下代码创建一个弹出菜单:
import UIKit
class BeobachtungViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBAction func addClicked(_ sender: AnyObject) {
// get a reference to the view controller for the popover
let popController = UIStoryboard(name: "Personenakte", bundle: nil).instantiateViewController(withIdentifier: "popoverId")
// set the presentation style
popController.modalPresentationStyle = UIModalPresentationStyle.popover
// set up the popover presentation controller
popController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
popController.popoverPresentationController?.delegate = self
popController.popoverPresentationController?.sourceView = sender as! UIView // button
popController.popoverPresentationController?.sourceRect = sender.bounds
// present the popover
self.present(popController, animated: true, completion: nil)
}
// UIPopoverPresentationControllerDelegate method
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) …
Run Code Online (Sandbox Code Playgroud) 这个问题的关键是要说明Java没有像我预期的那样工作.
您希望以下代码如何表现?
public class SynchTester {
private static SynchTester synchTester;
public synchronized static SynchTester getSynchTester(){
if(synchTester==null){
synchTester = new SynchTester();
}
return synchTester;
}
private SynchTester() {
SynchTester myTester = getSynchTester();
}
public static void main(String[] args) {
SynchTester tester = SynchTester.getSynchTester();
}
}
Run Code Online (Sandbox Code Playgroud)
我希望它挂起一个死锁等待递归完成,但它会抛出StackOverflow.显然,synchronized不会阻止访问同一个线程.
这是一个错误吗?
有没有人看到这个SQL Server代码有什么问题?
IF NOT EXISTS(SELECT *
FROM sys.columns
WHERE Name = 'OPT_LOCK'
AND object_ID = Object_id('REP_DSGN_SEC_GRP_LNK'))
BEGIN
ALTER TABLE REP_DSGN_SEC_GRP_LNK
ADD OPT_LOCK NUMERIC(10, 0)
UPDATE REP_DSGN_SEC_GRP_LNK
SET OPT_LOCK = 0
ALTER TABLE REP_DSGN_SEC_GRP_LNK
ALTER COLUMN OPT_LOCK NUMERIC(10, 0) NOT NULL
END;
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我得到:
消息207,级别16,状态1,行3
无效的列名称"OPT_LOCK".
在更新命令上.
谢谢.
我有一个例外,没有得到很好的处理.我在调试器中的一行,我手头有异常,但它不在我的代码中,所以我不能在那时记录它.所以我坐在调试器中,我的变量窗口中有异常,我正在试图弄清楚如何从中获取堆栈跟踪,以便我可以找到异常发起的位置并更好地处理它.
想法?
我有@MappedSuperClass
(简化的例子):
@MappedSuperclass
public abstract class MySuperClass {
@Id
@GeneratedValue
private long id;
@Column(nullable = false)
private Date creationDate;
// ...
}
Run Code Online (Sandbox Code Playgroud)
和具体的Entity
(简化例子):
@Entity
public class MyEntity extends MySuperClass {
@Index(name = "IDX_MYINDEX")
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private MyType type;
@Index(name = "IDX_MYINDEX")
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private MyResult status;
// ...
}
Run Code Online (Sandbox Code Playgroud)
现在我需要包括列的索引MySuperClass.creationDate
,MyEntity.status
和MyEntity.type
.
如果我添加@Index(name = "IDX_MYINDEX")
到MySuperClass.creationDate
hibernate,则为creationDate
每个继承的Entity 添加一个索引MySuperClass
.
我试过@AttributeOverride
但它不能用于索引.
有任何想法吗?TIA!
java ×6
jpa ×2
angular ×1
ddl ×1
dictionary ×1
eclipse ×1
hibernate ×1
ios ×1
iphone ×1
json ×1
popover ×1
recursion ×1
spring ×1
spring-boot ×1
spring-data ×1
sql ×1
sql-server ×1
swift ×1
swift3 ×1
synchronized ×1
t-sql ×1