「yo jhipster:entity」コマンドを使用して3つのエンティティ(Author、Book、Library)を作成しましたが、1つのエンティティ(Library)で(Bookとの)ManyToMany関係がありましたが、「mappedBy reference unknown unknown entity entity property:com。 tst.testdomain.domain.Book.librarys in com.tst.testdomain.docmain.Library.books」のように、ライブラリエンティティを削除するクリーンな方法は何ですか。 「yo jhipster:entitydelete」のようなコマンドは役に立ちますか?
これにはgit scmを使用します。削除する必要があるのは、生成されたファイルだけではありません。 jHipsterはファイルを変更するため、ファイルを保持する必要があるが、変更を元に戻す必要があるファイルも使用します。
エンティティを作成するたびに、jHipsterが各エンティティに対して行ったことを追跡できるように、個別のコミットを行います。
最後のコミット以降のすべての変更をクリアするには
git reset --hard
git clean -fd
私がそれをやったが、以前のコミットをバックアウトする必要がある場合は、
git reset --hard HEAD~1
コミットはgitではローカルであるため、これらのコミットをプッシュするまで共有は共有されません。
以下を削除する必要があります。
rm -rf src/main/resources/config/liquibase/changelog/XXX_added_entity_YourEntity.xml
rm -rf src/main/Java/com/radsphere/jeces/domain/YourEntity.Java
rm -rf src/main/Java/com/radsphere/jeces/repository/YourEntityRepository.Java
rm -rf src/main/Java/com/radsphere/jeces/web/rest/YourEntityResource.Java
rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntitys.html
rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity-detail.html
rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity.js
rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity.controller.js
rm -rf src/main/webapp/scripts/app/entities/YourEntity/YourEntity-detail.controller.js
rm -rf src/main/webapp/scripts/components/entities/YourEntity/YourEntity.service.js
rm -rf src/test/Java/com/radsphere/jeces/web/rest/YourEntityResourceTest.Java
rm -rf src/main/webapp/i18n/en/YourEntity.json
rm -rf src/main/webapp/i18n/fr/YourEntity.json
Config/liquibase/master.xmlから参照を削除します。
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307175923_added_entity_Company.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307180142_added_entity_UserTypeRecruiter.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307180338_added_entity_UserTypeCandidate.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307180448_added_entity_QuestionType.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307180612_added_entity_Question.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307180849_added_entity_Answer.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307181033_added_entity_CandidateAnswer.xml" relativeToChangelogFile="false"/>
<!--<include file="classpath:config/liquibase/changelog/20150307181249_added_entity_your_removed_entity.xml" relativeToChangelogFile="false"/>-->
<include file="classpath:config/liquibase/changelog/20150307182736_added_entity_ExamTemplate.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20150307182950_added_entity_Exam.xml" relativeToChangelogFile="false"/>
<!-- JHipster will add liquibase changelogs here -->
この機能を追加するためにプルリクエストを行います: https://github.com/jhipster/generator-jhipster/pull/4369
それを使用するには、非常に簡単です:
yo jhipster:entity Foo --remove
Liquibaseスクリプトは削除されますが、既に作成されてまだドロップされていないテーブル/列ファミリを処理する必要があります。
これに興味がある場合は、問題に投票またはコメントしてください: https://github.com/jhipster/generator-jhipster/issues/4372
ディレクトリ.jhipster/entityName.jsonのエンティティを削除するだけで簡単です。
「yo:jhipster entity」を再度実行して、他のすべてをオーバーライドできます。
ミーム。
削除コマンドが役立つと思います。しかし、このコマンドは今日存在しません。おそらく追加されます。エンティティを削除する場合は、手動で削除する必要があります。エンティティ用に生成されたすべてのファイルを削除します:ドメイン、リポジトリ、残り、テスト、Angularjsコントローラーとサービス、HTMLビュー、メニュー内のリンク、HTMLビュー
[〜#〜] edited [〜#〜]:jhipster 3.9.0の新しいバージョンのスクリプトを追加
私のdelete-entity.shjhipsterのスクリプト リリース2.26.2 、@ shacharsolの回答に基づきます。
使用法:./delete-entity GROUP_ID ENTITY_NAME
GROUP_ID:com/subpackage/and/so/on /(「/」で終わる)
ENTITY_NAME:firstLowercaseNameOfEntity
例:./delete-entity uz/javlon/transInfo
#!/usr/bin/env bash
echo "################";
if [ -z "$1" ];
then
printf "Required argument GROUP_ID is not set. \nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME.\n";
exit 1;
else
GROUP_ID=$1;
echo "GROUP_ID is set to '$1'.";
fi
if [ -z "$2" ];
then
printf "Required argument ENTITY_NAME is not set. \nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME .\n";
exit 1;
else
ENTITY_NAME=$2;
echo "ENTITY_NAME is set to '$2'.";
fi
echo;
rm -rf src/main/resources/config/liquibase/changelog/*_added_entity_${ENTITY_NAME^}.xml
rm -rf src/main/Java/${GROUP_ID}domain/${ENTITY_NAME^}.Java
rm -rf src/main/Java/${GROUP_ID}repository/${ENTITY_NAME^}Repository.Java
rm -rf src/main/Java/${GROUP_ID}repository/search/${ENTITY_NAME^}SearchRepository.Java
rm -rf src/main/Java/${GROUP_ID}web/rest/${ENTITY_NAME^}Resource.Java
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}s.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}
rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.service.js
rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.search.service.js
rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}
rm -rf src/test/Java/${GROUP_ID}web/rest/${ENTITY_NAME^}ResourceIntTest.Java
rm -rf src/test/gatling/simulations/${ENTITY_NAME^}GatlingTest.scala
rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.spec.js
rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME}
rm -rf src/main/webapp/i18n/en/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/ru/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/uz/${ENTITY_NAME}.json
rm -rf ./.jhipster/${ENTITY_NAME^}.json
echo;
echo "Deleting ${ENTITY_NAME^} is completed.";
echo "################";
私の別のdelete-entity.shjhipsterのスクリプト リリース3.9. 、@ Tevfik Kizilorenの回答に基づきます。
#!/usr/bin/env bash
echo;
if [ -z "$1" ];
then
printf "Required argument GROUP_ID is not set. \nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME.\n";
exit 1;
else
GROUP_ID=$1;
echo "GROUP_ID is set to '$1'.";
fi
if [ -z "$2" ];
then
printf "Required argument ENTITY_NAME is not set. \nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME .\n";
exit 1;
else
ENTITY_NAME=$2;
Java_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr '[a-z]' '[A-Z]'`${ENTITY_NAME:1}
echo "ENTITY_NAME is set to '$2'."
echo "Java entity name inferred as: '${Java_ENTITY_NAME}'.";
fi
Java_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr '[a-z]' '[A-Z]'`${ENTITY_NAME:1}
UNDERSCORED_FOLDER_NAME=`echo ${ENTITY_NAME} | sed -r 's/([a-z0-9])([A-Z])/\1-\L\2/g'`
echo ${UNDERSCORED_FOLDER_NAME};
QUESTION=$'You may want to keep definition file(.jhipster/'${Java_ENTITY_NAME}'.json) in case you want to regenerate entity in the future.\nDo you want to delete entity definition file also?'
while true; do
read -p "${QUESTION}" yn
case $yn in
[Yy]* ) rm -rf ./.jhipster/${ENTITY_NAME}.json; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
echo;
echo "Starting to delete files...";
rm -rf src/main/resources/config/liquibase/changelog/*_added_entity_${Java_ENTITY_NAME}.xml
rm -rf src/main/Java/${GROUP_ID}domain/${Java_ENTITY_NAME}.Java
rm -rf src/main/Java/${GROUP_ID}repository/${Java_ENTITY_NAME}Repository.Java
rm -rf src/main/Java/${GROUP_ID}service/${Java_ENTITY_NAME}Service.Java
rm -rf src/main/Java/${GROUP_ID}service/impl/${Java_ENTITY_NAME}ServiceImpl.Java
rm -rf src/main/Java/${GROUP_ID}repository/search/${Java_ENTITY_NAME}SearchRepository.Java
rm -rf src/main/Java/${GROUP_ID}web/rest/${Java_ENTITY_NAME}Resource.Java
rm -rf src/main/Java/${GROUP_ID}web/rest/dto/${Java_ENTITY_NAME}DTO.Java
rm -rf src/main/Java/${GROUP_ID}web/rest/mapper/${Java_ENTITY_NAME}Mapper.Java
rm -rf target/generated-sources/${GROUP_ID}web/rest/mapper/${Java_ENTITY_NAME}MapperImpl.Java
rm -rf src/main/webapp/app/entities/${UNDERSCORED_FOLDER_NAME}/*
rm -rf src/test/Java/${GROUP_ID}web/rest/${Java_ENTITY_NAME}ResourceIntTest.Java
rm -rf src/test/gatling/simulations/${Java_ENTITY_NAME}GatlingTest.scala
rm -rf src/test/javascript/spec/app/entities/${UNDERSCORED_FOLDER_NAME}/*
rm -rf src/test/javascript/spec/app/entities/${UNDERSCORED_FOLDER_NAME}
rm -rf src/main/webapp/i18n/en/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/fr/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/ru/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/uz/${ENTITY_NAME}.json
echo "Deleting entity '${ENTITY_NAME}' is completed.";
echo;
echo "-----------------------------------------------------";
echo "Do not forget to manually correct these files also: ";
echo "-----------------------------------------------------";
echo " --> src/main/webapp/index.html"
echo " --> src/main/webapp/scripts/compopnents/navbar.html"
echo " --> src/main/webapp/i18n/**/global.json"
echo " --> src/main/resources/config/liquibase/master.xml (if you use liquibase)"
echo " --> src/main/resources/config/mongeez/master.xml (if you use mongodb)"
SparXとMemeの回答にいくつか追加しました。
SparXのbashスクリプト(delete-entity.sh)を更新して、エンティティ定義ファイルを削除するかどうかを尋ねました。また、"$ {ENTITY_NAME ^}"構文(エンティティ名の最初の文字を大文字に変換するために使用されます)は、古いbashバージョン(3.2など)では実行されません。
更新されたbashスクリプトは以下のとおりです。 pom.xmlがあるフォルダーにこのスクリプトを置くだけです。
ユースケースの例:プロジェクトのgroupIdの場合"com.example"および"city"という名前のエンティティを削除する場合、例コマンドは以下のとおりです。
./ delete-entity.sh com/example/city
#!/usr/bin/env bash
echo;
if [ -z "$1" ];
then
printf "Required argument GROUP_ID is not set. \nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME.\n";
exit 1;
else
GROUP_ID=$1;
echo "GROUP_ID is set to '$1'.";
fi
if [ -z "$2" ];
then
printf "Required argument ENTITY_NAME is not set. \nUsage: ./delete-entity.sh GROUP_ID ENTITY_NAME .\n";
exit 1;
else
ENTITY_NAME=$2;
Java_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr '[a-z]' '[A-Z]'`${ENTITY_NAME:1}
echo "ENTITY_NAME is set to '$2'."
echo "Java entity name inferred as: '${Java_ENTITY_NAME}'.";
fi
Java_ENTITY_NAME=`echo ${ENTITY_NAME:0:1} | tr '[a-z]' '[A-Z]'`${ENTITY_NAME:1}
QUESTION=$'You may want to keep definition file(.jhipster/${Java_ENTITY_NAME}.json) in case you want to regenerate entity in the future.\nDo you want to delete entity definition file also?'
while true; do
read -p "${QUESTION}" yn
case $yn in
[Yy]* ) rm -rf ./.jhipster/${ENTITY_NAME}.json; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
echo;
echo "Starting to delete files...";
rm -rf src/main/resources/config/liquibase/changelog/*_added_entity_${Java_ENTITY_NAME}.xml
rm -rf src/main/Java/${GROUP_ID}domain/${Java_ENTITY_NAME}.Java
rm -rf src/main/Java/${GROUP_ID}repository/${Java_ENTITY_NAME}Repository.Java
rm -rf src/main/Java/${GROUP_ID}service/${Java_ENTITY_NAME}Service.Java
rm -rf src/main/Java/${GROUP_ID}service/impl/${Java_ENTITY_NAME}ServiceImpl.Java
rm -rf src/main/Java/${GROUP_ID}repository/search/${Java_ENTITY_NAME}SearchRepository.Java
rm -rf src/main/Java/${GROUP_ID}web/rest/${Java_ENTITY_NAME}Resource.Java
rm -rf src/main/Java/${GROUP_ID}web/rest/dto/${Java_ENTITY_NAME}DTO.Java
rm -rf src/main/Java/${GROUP_ID}web/rest/mapper/${Java_ENTITY_NAME}Mapper.Java
rm -rf target/generated-sources/${GROUP_ID}web/rest/mapper/${Java_ENTITY_NAME}MapperImpl.Java
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}s.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-dialog.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.html
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-delete-dialog.controller.js
rm -rf src/main/webapp/scripts/app/entities/${ENTITY_NAME}
rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.service.js
rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}/${ENTITY_NAME}.search.service.js
rm -rf src/main/webapp/scripts/components/entities/${ENTITY_NAME}
rm -rf src/test/Java/${GROUP_ID}web/rest/${ENTITY_NAME}ResourceIntTest.Java
rm -rf src/test/gatling/simulations/${ENTITY_NAME}GatlingTest.scala
rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME}/${ENTITY_NAME}-detail.controller.spec.js
rm -rf src/test/javascript/spec/app/entities/${ENTITY_NAME}
rm -rf src/main/webapp/i18n/en/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/fr/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/ru/${ENTITY_NAME}.json
rm -rf src/main/webapp/i18n/uz/${ENTITY_NAME}.json
echo "Deleting entity '${ENTITY_NAME}' is completed.";
echo;
echo "-----------------------------------------------------";
echo "Do not forget to manually correct these files also: ";
echo "-----------------------------------------------------";
echo " --> src/main/webapp/index.html"
echo " --> src/main/webapp/scripts/compopnents/navbar.html"
echo " --> src/main/webapp/i18n/**/global.json"
echo " --> src/main/resources/config/liquibase/master.xml (if you use liquibase)"
echo " --> src/main/resources/config/mongeez/master.xml (if you use mongodb)"