我创建了一个 build.xml 来编译我的源文件并创建一个 jar。当我运行构建时创建了 jar,但是 jar 运行时出现以下异常
[java] Exception in thread "main" java.lang.NoClassDefFoundError: com/mysql
/jdbc/exceptions/MySQLIntegrityConstraintViolationException
构建文件是:
<?xml version="1.0"?>
<project name="NmzAzzist" basedir="." default="main">
<property name="src.dir" value="../Source/NMSAzzist/src" />
<property name="build.dir" value="ReleaseBuild/classes" />
<property name="jar.dir" value="ReleaseBuild/ReleaseJars" />
<path id="master-classpath">
<fileset dir="Libraries">
<include name="*.jar" />
</fileset>
</path>
<patternset id="meta.files">
<include name="**/*.xml" />
<include name="**/*.properties" />
<include name="**/*.mib" />
</patternset>
<!-- Simply extends the compile.classpath with your own compiled classes. -->
<target name="clean" description="Clean output directories">
<delete dir="${build.dir}" />
</target>
<target name="build" description="Compile source tree java files">
<echo>Compiling the source code</echo>
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.5" target="1.5"
includeantruntime="false">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
</target>
<target name="copy.meta.files">
<copy todir="${build.dir}">
<fileset dir="${src.dir}">
<patternset refid="meta.files" />
</fileset>
</copy>
</target>
<target name="jar" depends="build, copy.meta.files">
<mkdir dir="${jar.dir}" />
<echo>building jar!</echo>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class"
value="com.ushustech.nmsazzist.NMSAzzistApp" />
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true" />
</target>
<target name="main" depends="clean,run" />
</project>
我该如何解决这个问题?