为什么ApplicationContext和ClasspathXmlApplicationContext在此处被视为错误

时间:2015-08-12 17:19:02

标签: java spring

我正在学习Spring并且在这段代码中遇到错误;在第1行。 import org.springframework.beans.factory.BeanFactory;

var gulp = require('gulp'),
browserSync = require('browser-sync'),
del = require('del'),
autoprefixer = require('gulp-autoprefixer'),
cache = require('gulp-cache'),
concat = require('gulp-concat'),
imagemin = require('gulp-imagemin'),
jade = require('gulp-jade'),
jshint = require('gulp-jshint'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
cp = require('child_process');

var messages = {
    jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};

/**
 * Build the Jekyll Site
 */
gulp.task('jekyll-build', function (done) {
    return cp.spawn('jekyll.bat', ['build'], {stdio: 'inherit'})
        .on('close', done);
});

/**
 * Rebuild Jekyll & do page reload
 */
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
    browserSync.reload();
});

/**
 * Wait for jekyll-build, then launch the Server
 */
gulp.task('browser-sync', ['sass', 'scripts', 'images', 'jade', 'jekyll-build'], function() {
    browserSync({
        server: {
            baseDir: 'dist/'
        }
    });
});

/**
 * Compile files from _scss into both _site/css (for live injecting) and site (for future jekyll builds)
 */
gulp.task('sass', function () {
    return gulp.src('_css/main.sass')
        .pipe(sass({
            includePaths: ['sass'],
            onError: browserSync.notify
        }))
        .pipe(autoprefixer(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], { cascade: true }))
        .pipe(gulp.dest('dist/assets/css'))
        .pipe(browserSync.reload({stream:true}));
});

gulp.task('scripts', function() {
  return gulp.src('_js/**/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(concat('main.js'))
    .pipe(gulp.dest('dist/assets/js'))
    .pipe(browserSync.reload({stream:true}));
});

gulp.task('images', function() {
  return gulp.src('_img/**/*')
    .pipe(cache(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true })))
    .pipe(gulp.dest('dist/assets/img'))
    .pipe(browserSync.reload({stream:true}));
});

gulp.task('jade', function() {
  return gulp.src('_templates/**/*.jade')
    .pipe(jade())
    .pipe(gulp.dest('_templates/'))
    .pipe(browserSync.reload({stream: true}));
});

/**
 * Watch scss files for changes & recompile
 * Watch html/md files, run jekyll & reload BrowserSync
 */
gulp.task('watch', function () {
    gulp.watch('_css/**/*.sass', ['sass']);
    gulp.watch('_img/**/*'), ['images'];
    gulp.watch('_js/**/*.js'), ['scripts'];
    gulp.watch('_templates/**/*.jade'), ['jade'];
    gulp.watch(['index.html', '_templates/*.html'], ['jekyll-rebuild']);
});

/**
 * Default task, running just `gulp` will compile the sass,
 * compile the jekyll site, launch BrowserSync & watch files.
 */
gulp.task('default', ['browser-sync', 'watch']);

显示错误: - ApplicationContext无法解析为类型 ClassPathXmlApplicationContext无法解析为类型

2 个答案:

答案 0 :(得分:4)

ApplicationContext和ClassPathXmlApplicationContext缺少import语句。

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

答案 1 :(得分:0)

在lib中包含spring core工件,或者如果pom.xml文件可用,则运行可以解析工件的mvn eclipse命令