亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在終端中編譯 Spring 項目時出現 NoClassDefFoundError

在終端中編譯 Spring 項目時出現 NoClassDefFoundError

料青山看我應如是 2022-06-08 16:48:04
我正在嘗試學習 Spring,并且正在關注本教程:https://www.javatpoint.com/spring-tutorial。這是我所做的:我創建了一個目錄springtutorial并將這兩個文件放入其中:Student.javapackage com.javatpoint; public class Student{        private String name;        public String getName(){                return name;        }        public void displayInfo(){                System.out.println("Hello:" + name);        }}Test.java:package com.javatpoint;import org.springframework.beans.factory.BeanFactory;import org.springframework.beans.factory.xml.XmlBeanFactory;import org.springframework.core.io.ClassPathResource;import org.springframework.core.io.Resource;public class Test {        public static void main(String[] args){                Resource resource = new ClassPathResource("applicationContext.xml");                BeanFactory factory = new XmlBeanFactory(resource);                Student student = (Student) factory.getBean("studentbean");                student.displayInfo();        }}另外,我創建了一個 XML 文件applicationContext.xml:<?xml version="1.0" encoding="UTF-8"?><beans        xmlns="https://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xmlns:p="http://www.springframework.org/schema/p"        xsi:schemaLocation="http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">        <bean id="studentbean" class="com.javatpoint.Student">                <propertyname="name" value="Vimal Jaiswal"></property>        </bean></beans>最后,我下載了這些 Spring 核心文件:https ://www.javatpoint.com/src/sp/spcorejars.zip通過在線查看,在我看來,我應該擁有我需要的所有 .jar 文件。那么這個錯誤的原因可能是什么?在你問之前:不,我不想使用 Maven 或 Gradle 來做這件事。這樣做的目的是在沒有任何程序為您執行的情況下查看一切實際上是如何工作的。
查看完整描述

1 回答

?
鳳凰求蠱

TA貢獻1825條經驗 獲得超4個贊

嘗試運行命令:

~/springtutorial$ java -cp ".:spcorejars/*" com.javatpoint.Test


查看完整回答
反對 回復 2022-06-08
  • 1 回答
  • 0 關注
  • 136 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號