开发者

ClassNotFoundException when starting Maven 2 RCP application

I've started a very basic Eclipse (Helios) RCP application with the "Hello RCP" template.

I enabled Maven dependency management and added Spring 3 to the POM.

After that I created a view and added the following code to my view.

@Override
public void createPartControl(Composite parent) {
 RestTemplate restTemplate = new RestTemplate();
    String result = restTemplate.getForObject("http://www.example.com:8080/rest/{page}/{id}" , String.class, "mypage", "someid");
 Text text = new Text(parent, SWT.BORDER);
 text.setText(result开发者_如何学编程);
}

When I run the application, I get the following exception,

java.lang.ClassNotFoundException: org.springframework.web.client.RestTemplate
...

I can post the rest if need be.

I'm wondering how I can add the maven dependencies to my classpath or if something else may be the problem?

Thanks


Are you running your program from Maven ? If you do this, then the classpath should automatically be correct.

Briefly:

$ mvn exec:java -Dexec.mainClass="com.whatever.Main"

See this link for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜