我正在学习如何用Java创建一些应用程序,我在教程中找到了一个maven项目示例,然后在netbeans中编译它.
我试图在互联网上搜索如何将maven项目导入netbeans,我找不到解决方案.
顺便说一句,在教程中我下载了类似pom.xml的东西,我想知道它是什么以及如何使用它?
谢谢!
我在两个实体之间有一个多对多的关系:汽车和经销商.
在原生MySQL中我有:
car (id and other values)
dealership (id and other values)
car_dealership (car_id and dealership_id)
Run Code Online (Sandbox Code Playgroud)
我想在JPQL中创建的查询是:
#Select List of cars in multiple dealerships
SELECT car_id FROM car_dealership WHERE dealership_id IN(1,2,3,56,78,999);
Run Code Online (Sandbox Code Playgroud)
使JPQL等效的正确方法是什么?
我的Java方法签名是:
public List<Car> findByDealership(List<Dealership> dealerships);
Run Code Online (Sandbox Code Playgroud)
我试过了
//TOTALLY WRONG QUERY CALL!!!
Query query = em.createQuery("SELECT c FROM Car c WHERE :dealer_ids IN c.dealerships");
List<Long> dealerIds = new ArrayList<Long>();
for(Dealership d : dealerships) {
dealerIds.add(d.getId());
}
query.setParameter(":dealer_ids", dealerIds);
List<Dealership> result = (List<Dealership>) query.getResultList();
return result;
}
Run Code Online (Sandbox Code Playgroud)
这是我在java中的这种关系的JPA注释:
@Entity
@Table(name = …
Run Code Online (Sandbox Code Playgroud) 我使用Mac OS,10.6并在恢复备份数据后,Eclipse停止工作.它给了我以下错误:
The container 'JRE System Library [JavaSE-1.6]' references non existing library '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar'
Unbound classpath container: 'JRE System Library [JavaSE-1.7]' in project 'Proba'
Run Code Online (Sandbox Code Playgroud)
我试图再次安装Java Development Kit(帮助 - >安装新软件),Eclipse实际安装了它,但是当我去(Eclipse - > Preferences - > Java - > Installed JREs)时,我收到错误"Installed JRE location no longer exists. JRE will be removed. Reason: JRE removed"
,并安装了JREs窗口确实是空的.Java代码仍然无法编译.
解决方案:转到:Eclipse -> Preferences -> Java -> Installed JREs -> Execution Environment
并选择JAVA SE 6软件包(可能JAVA SE 7可以工作),然后在右侧选择兼容的JRE.
重新加载Eclipse.
我有一个本地邮件服务器(hMailServer)与SSL(端口465)和自签名证书.
域名是"foobar.com"
我设置了我Properties
的启用ssl,禁用auth,并信任任何主机
props.put("mail.smtp.auth", "false");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.trust", "*");
Run Code Online (Sandbox Code Playgroud)
如果我通过静态呼叫发送消息,则Transport.send()
电子邮件将被发送.
如果我尝试transport
从会话中获取实例,那么我得到
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Run Code Online (Sandbox Code Playgroud)
静态调用如何避免SSLHandshakeException?
这是我的测试人员代码:
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.put("mail.smtp.host", "127.0.0.1");
props.put("mail.debug", "false");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.timeout", "60000");
props.put("mail.smtp.auth", "false");
props.put("mail.smtp.sendpartial", "true");
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.trust", "*");
Session session = Session.getInstance(props);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("mrFoo@foobar.com"));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("you@foobar.com"));
message.setSubject("Just a Test …
Run Code Online (Sandbox Code Playgroud) 我遇到此错误消息:
TypeError: add_header() takes exactly 3 arguments (2 given)
使用这些参数时:
testService("SomeServiceName", "POST", "[redacted valid url]", ('Content-type','application/json'), [redacted valid json])
通常这个错误意味着我没有将"self"作为参数传递,但是看到这个方法没有在类中调用,我不知道该怎么做.我已经尝试将self in作为参数传递给参数和方法内部.我已经尝试将标题括在括号和括号中.当我传递"self"时,我收到self未定义的错误消息,当我使用括号而不是括号时,我得到与上面相同的错误.
有魔术Python调试技巧的人吗?非常感谢您抽出宝贵的时间来检查这个!
def testService(name, verb, url, header="", requestBody=""):
#Log out the name of the request we're testing
if (name is not None) or (name.strip() is not ""):
print "Checking " + name + "\n\n"
# Make URL with StoreNumber
if (url is not None) or (url is not ""):
testUrl = url
# If specified verb is GET …
Run Code Online (Sandbox Code Playgroud) 下面的C++代码是做什么的?更具体地说,运营商是|=
什么?
long liFaultFlags = 0;
for (int i = 0; i < FAULTCOUNT; i++)
{
if (faults[i] == true)
{
liFaultFlags |= (1 << i);
}
}
return liFaultFlags;
Run Code Online (Sandbox Code Playgroud)
如何在C#中实现?
我正在编写一个简单的2D迷宫游戏,你可以通过很多房间.我想通过限制玩家的观点来使其有点挑战.起初我想过将框架中的默认鼠标图标替换为半透明的PNG椭圆,但后来我意识到我需要阻止它周围的东西.
我能想到的唯一方法是将鼠标指针图标设置为大于框架的图像(因此当用户移动到角落时仍然是黑色时)将其填入然后放置清晰褪色的椭圆在指针区域.
我想知道的是,这是可能的,我将如何做到这一点?我正在学习java,所以示例和oracle文档对我很有帮助.提前致谢!
从这里看到这个链接(加载需要一段时间)PS:我正在使用eclipse.
所以我曾经为iOS6提供以下代码片段
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if([[UIApplication sharedApplication] canOpenURL:instagramURL])
{
NSURL *imageURL = [NSURL fileURLWithPath:originalImagePath];
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:imageURL];
self.documentInteractionController.delegate = self;
self.documentInteractionController.UTI = @"com.instagram.exclusivegram";
[self.documentInteractionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
但随着iOS7的发布,我得到一个对话框窗口,显示Instagram中的Open图标,我收到以下错误:
Invalid LSOpenOperation request - No applications found to open document
有谁知道Instagram是否已经改变了他们UTI
的iOS7或适当的开发人员钩子,使其在7上工作?
简单的测试案例:
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public static void main(String[] args) throws Exception {
String json = "1,2";
ObjectMapper parser = new ObjectMapper();
JsonNode rootNode = parser.readTree(json);
}
Run Code Online (Sandbox Code Playgroud)
引发异常:
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException:
Unexpected character (',' (code 44)): Expected space separating root-level values
at [Source: 1,2; line: 1, column: 3]
Run Code Online (Sandbox Code Playgroud)
一切都很好,但如果我更改String json
为以下任何一个,则:
String json = "null,false";
String json = "[1,2,3,null,\"hello\"],false";
String json = "true,3";
String json = "true,{\"test\":3}";
Run Code Online (Sandbox Code Playgroud)
没有抛出异常。
为什么会有差异?
我正在创建一个具有这两种方法的程序,我无法弄清楚.它们是"撤回"和"存款",它们位于CheckingAccount类中.在这些方法中,我想最初将值设为0然后添加到它.然后我想取新数字并从中减去.我想"存款"250美元.然后我想'退出'98美元.我不确定在哪里存储这些值以及如何执行它们.我有一个显示器应该看到的结果,而我离开撤销和存款方法是空的.
账户类别:
class Account
{
protected string firstName;
protected string lastName;
protected long number;
public string FirstName
{
set
{
firstName = value;
}
}
public string LastName
{
set
{
lastName = value;
}
}
public long Number
{
set
{
number = value;
}
}
public override string ToString()
{
return firstName + " " + lastName + "\nAccount #: " + number;
}
}
}
Run Code Online (Sandbox Code Playgroud)
检查帐户类别:
class CheckingAccount : Account
{
private decimal balance;
public CheckingAccount(string firstName, …
Run Code Online (Sandbox Code Playgroud)