Automatic defect inspection is an important application for the development of smart factories in the era of Industry 4.0. It gathers data from production lines to train a model to automatically recognize certain types of defects. However, the defect types may vary in the production process, and it is difficult for the old model to adapt to new types of defects directly. Considering this problem, we propose an industrial defect classification framework based on lifelong learning, which continuously updates the defect classification model to adapt to different industrial scenarios as new defect appears. Specifically, a novel recursive gradient optimization (RGO) lifelong learning method is used to train the defect classification model, which only needs a fixed network capacity and does not need data replay. The proposed framework is evaluated on an experimental setup of six defect classification tasks. Extensive experiments in real scenarios are performed, demonstrating that the proposed framework can effectively relieve the catastrophic forgetting problem in lifelong learning compared with other state-of-the-art methods.